62,271
社区成员
发帖
与我相关
我的任务
分享
string toFileFullPath = HttpContext.Current.Server.MapPath("../../" + TURL + "/");
//创建文件夹
if (!Directory.Exists(toFileFullPath))
{
return "文件夹不存在";
}
else
{
//网上这一段是设置文件夹为正常,但我设置后,还是会提示:对路径“E:\Software Develop\gdjtsg\ddd\”的访问被拒绝 FileInfo file = new FileInfo(toFileFullPath);
if (file.Attributes.ToString().IndexOf("ReadOnly") != -1)
{
file.Attributes = FileAttributes.Directory & FileAttributes.Normal;
}
File.Delete(toFileFullPath);
return "删除成功";
}
String directoryPath = Server.MapPath("\\Test");
DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
FileInfo[] fileInfos = directoryInfo.GetFiles();
foreach (FileInfo info in fileInfos)
{
if (info.IsReadOnly)
{
File.Delete(info.FullName);
}
}