目录删除问题:自己创建的临时目录已经删除了,却报错:目录非空?????????
我在上传文件的时候创建了临时目录,想在第二天把它删除,如下,问题如题:
string path=@"C:\temp";
if(Directory.Exists(path))
{
foreach(string cPath in Directory.GetDirectories(path))
{
if(Directory.GetCreationTime(cPath)<DateTime.Today)
{
try
{
Directory.Delete(path,true);
}
catch(Exception e)
{
Resonse.Write (e.ToString());
}
}
}
}