/// <summary>
/// 清空文件
/// </summary>
/// <param name="strPath"></param>
/// <returns></returns>
public bool DeleteDir(string strPath)
{
try
{
strPath = strPath.Trim().ToString();
if (System.IO.Directory.Exists(strPath))
{
string[] strDirs = System.IO.Directory.GetDirectories(strPath);
string[] strFiles = System.IO.Directory.GetFiles(strPath);
foreach (string strFile in strFiles)
{
System.IO.File.Delete(strFile);
}
foreach (string strdir in strDirs)
{
System.IO.Directory.Delete(strdir, true);
}
}
return true;
}
catch (Exception Exp) // 异常处理
{
// 异常信息
System.Diagnostics.Debug.Write(Exp.Message.ToString());
// 失败
return false;
}
}