if (Directory.Exists(oldPath))
{
??????????????? Directory.Move(oldPath, path);
if (OADBHelper.GetInt(sql) > 0)
{
Response.Write("alert('更新成功!');");
}
else
{
Response.Write("alert('更新失??!');");
}
}
else
{
Response.Write("alert('更新失?。?);");
}
}
如果遇到此種情況:用Directory.Move移動(dòng)文件夾改名是報(bào)錯(cuò)路徑拒絕訪問。
最簡單的,你嘗試下移動(dòng)文件夾改名時(shí),在計(jì)算上直接操作。不用代碼??纯词遣皇窃L問也被拒絕。
如果拒絕,說明本身文件夾存在沖突,拒絕訪問。
一般都是這樣的情況引起的。結(jié)束一些占用的進(jìn)程等
采用Directory.Exists方法
string path=Server.MapPath("/file");
if(!Directory.Exists(path))
{
Directory.CreateDirectory("path");
}
if(Directory.Exists(path))
{
Directory.Delete(path,true); //true為遞歸刪除子文件內(nèi)容
}
此類使用的命名空間using System.IO;