Self deletable application in C# in one executable

前端 未结 7 1808
北荒
北荒 2020-11-30 23:26

Is it possible to make an application in C# that will be able to delete itself in some condition.

I need to write an updater for my application but I don\'t want the

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 23:38

    If you use Process.Start you can pass in the Del parameter and the path to the application you wish to delete.

    ProcessStartInfo Info=new ProcessStartInfo();
    Info.Arguments="/C choice /C Y /N /D Y /T 3 & Del "+
                   Application.ExecutablePath;
    Info.WindowStyle=ProcessWindowStyle.Hidden;
    Info.CreateNoWindow=true;
    Info.FileName="cmd.exe";
    Process.Start(Info); 
    

    Code snippet taken from this article

提交回复
热议问题