c#程序自删除

再分享一个小技巧,实现c#版本exe的自删除功能。

代码如下:

 

Process process = new Process();
Thread.CurrentThread.Priority = ThreadPriority.Highest;
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.FileName = "cmd";
startinfo.Arguments = "/c del /q " + Application.ExecutablePath;
startinfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo = startinfo;
process.Start();
Application.Exit();

 

在程序执行完毕的时候加上这段代码,exe运行完后就不见了~

测试操作系统:win7

posted @ 2015-04-17 13:57  火月  阅读(458)  评论(0编辑  收藏  举报