C# 删除文件夹下子文件夹
2021-05-07 06:27
标签:blog direct each tor dal creat append short name C# 删除文件夹下子文件夹 标签:blog direct each tor dal creat append short name 原文地址:http://www.cnblogs.com/xinbaba/p/7650334.html var pathstr="E:/Time";
try
{
if (Directory.Exists(pathstr))
{
//var strname=DateTime.Now.ToShortDateString().Replace("/","-")+".txt";
var dt=DateTime.Now;
DirectoryInfo pathinfo=new DirectoryInfo(pathstr);
foreach (DirectoryInfo paths in pathinfo.GetDirectories())
{
//File.AppendAllText("E:\\Time\\新建文件夹 (2)"+"/"+strname,DateTime.Now+"\r\n");
if (paths.CreationTime 1)))
{
paths.Delete();
}
}
}
}
catch (Exception ex)
{
File.AppendAllText("E:\\Time\\Errlog.txt",ex+"\r\n");
}