asp.net编程实现删除文件夹及文件夹下文件的方法
本文实例讲述了asp.net编程实现删除文件夹及文件夹下文件的方法。分享给大家供大家参考,具体如下:
//获取文件夹
stringpath=Server.MapPath("Image");
//获取文件夹中所有图片
if(Directory.GetFileSystemEntries(path).Length>0)
{
//遍历文件夹中所有文件
foreach(stringfileinDirectory.GetFiles(path))
{
//文件己存在
if(File.Exists(file))
{
FileInfofi=newFileInfo(file);
//判断当前文件属性是否是只读
if(fi.Attributes.ToString().IndexOf("ReadyOnly")>=0)
{
fi.Attributes=FileAttributes.Normal;
}
//删除文件
File.Delete(file);
}
}
//删除文件夹
Directory.Delete(path);
}
希望本文所述对大家asp.net程序设计有所帮助。
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短