首页 > Windows开发 > 详细

c#利用批处理清理大目录

时间:2017-08-06 20:20:59      阅读:230      评论:0      收藏:0      [点我收藏+]

 

//先保存一个批处理.再执行;

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);
}

c#利用批处理清理大目录

原文:http://www.cnblogs.com/zhoujgssp/p/7295769.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!