再分享一个小技巧,实现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
时间: 2024-11-05 22:48:14