Winform退出运行后,删除运行目录(批处理方法)

        /// <summary>
/// Winform程序退出删除运行目录 FormClosed调用
/// </summary>
private void DeletExeFile()
{
string fileName = @"C:\remove.bat";
StreamWriter bat = new StreamWriter(fileName, false, Encoding.Default);
string exePath = Application.ExecutablePath;
string dir = exePath.Substring(0, exePath.LastIndexOf('\\')); //目标目录
bat.WriteLine("cd..");
bat.WriteLine("ping -n 3 -w 100 202.96.128.96"); //设置延时
bat.WriteLine(string.Format("rd \"{0}\" /s /q", dir)); //强制删除目标目录 bat.Close();
ProcessStartInfo info = new ProcessStartInfo(fileName);
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
Environment.Exit(Environment.ExitCode);
}

Winform退出运行后,删除运行目录(批处理方法)

上一篇:Can't create session svn: Unable to connect to a repository at URL “...”的解决方案


下一篇:JS继续学习记录(一)