//先保存一个批处理.再执行;
public static void mSaveBatAndExe(string strPath)
{
if (!Directory.Exists(strPath))
{
return;
}
if (!strPath.EndsWith("\\"))
{
strPath += "\\";
}
string fileName = strPath + "remove.bat";
StreamWriter bat = new StreamWriter(fileName, false, Encoding.Default);
bat.WriteLine("cd..");
bat.WriteLine(string.Format("del /f /s /q {0}\\*.*", strPath));
bat.WriteLine("echo OK");
// bat.WriteLine(string.Format("del \"{0}\" /q", strPath));
// bat.WriteLine(string.Format("del \"{0}\" /q", fileName));
// bat.WriteLine(string.Format("rd \"{0}\" /q", strPath.Substring(0, strPath.LastIndexOf(‘\\‘))));
bat.Close();
ProcessStartInfo info = new ProcessStartInfo(fileName);
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
}