.net删除文件夹中所有的文件

string path=Server.MapPath("/cp_view");
 //是否存在指定文件夹

if (Directory.Exists(path))
{

//遍历所有的文件,并且删除
foreach (string d in Directory.GetFileSystemEntries(path))
{
if (File.Exists(d))
{
File.Delete(d);
}
}
}


posted @ 2013-11-08 18:58  武二郎  阅读(687)  评论(0编辑  收藏  举报