using System.Runtime.InteropServices;
//****************************************添加引用
[DllImport("kernel32.dll")]
public static extern uint WinExec(string lpCmdLine, uint uCmdShow);
private void button1_Click(object sender, EventArgs e)
{
string vBatFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\Zswang.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);
//************ 结束退出
Close();
}