| C#程序删除自身及所在目录
					当前位置:点晴教程→知识管理交流
					
					→『 技术文档交流 』
					
				 
 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Configuration; using System.Runtime.InteropServices; using System.Windows.Forms; namespace killself {     class Program     {         static void Main(string[] args)         {             BeginKillSelf();         }         [DllImport("kernel32.dll")]         public static extern uint WinExec(string lpCmdLine, uint uCmdShow);         private static  void BeginKillSelf()         {             string vBatFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\a.bat";             using (StreamWriter vStreamWriter = new StreamWriter(vBatFile, false, Encoding.Default))             {                 vStreamWriter.Write(string.Format(                 ":del\r\n" +                 " del \"{0}\"\r\n" +                 "if exist \"{0}\" goto del\r\n" +                  "del %0\r\n", Application.ExecutablePath));             }             WinExec(vBatFile, 0);             Process.GetCurrentProcess().Kill();             Environment.Exit(0);         }     } } 该文章在 2021/7/1 14:58:28 编辑过 | 关键字查询 相关文章 正在查询... |