How can I make my .NET application erase itself?

前端 未结 11 712
梦如初夏
梦如初夏 2020-12-08 10:37

How can I make my C# app erase itself (self-destruct)? Here\'s two ways that I think might work:

  • Supply another program that deletes the main program. How is t
11条回答
  •  星月不相逢
    2020-12-08 11:08

    There's a great CodeProject Article about this topic.

    Edit: Basically it's a simple cmd-call which will delete the specified files after some seconds.

    Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del " + Application.ExecutablePath); 
    Application.Exit();
    

提交回复
热议问题