0

So,I have tried to delete my own program after run it.When I open it,my code is working well,but then I need to delete it using C# and nothing happens,sometimes Microsoft Policy warm me that I can’t delete it using File.Delete or similar function.Also I tried to write some self delete void methods,but it doesn’t work...Finally if you also know how to delete files inside zip after using ZipFile.Create I will be pleased.

  • Take a look at https://stackoverflow.com/questions/19689054/is-it-possible-for-a-c-sharp-built-exe-to-self-delete/19689415 – Kluddizz Mar 25 '20 at 18:54

1 Answers1

1

You can't delete your running self-executable file because that is running already in the ram. So have a solution for that, make another c# application for delete ur exe file. And you can run that program when main program exit

Thirasha
  • 193
  • 2
  • 8
  • Thank you,should it be another project and how to compile both of them in 1 exe without any programs,using only c# – prom tom Mar 25 '20 at 19:17
  • make another c# application for delete ur main exe file like that i told. And then add that exe file to ur main project resources. after, when the main program exit you can write that exe file from resources to temp location and run it from the main program. then ur problem will be solved. – Thirasha Mar 26 '20 at 20:10