当我尝试剪切并粘贴目录(子文件夹和文件)时,它给了我错误访问路径被拒绝。有时当我将任何文件上传到该目录时,它会显示错误。
我可以完全访问该目录和子目录。 我能够删除并上传该目录下的文件,但无法将该目录移动到任何其他位置。
我试过了:
我也试过这个
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(
new FileSystemAccessRule("everyone", FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
//move function
Source = Server. MapPath (source);
destination = Server.MapPath(destination);
If (! Directory. Exists (destination))
{
Directory.Move(source, destination);
}
catch (Exception e)
{
return e.Message;
}
如果你知道我为什么会收到这个错误,请告诉我。
答案 0 :(得分:0)
“source”目录中的某个文件可能正在使用中,无法移动。尝试在循环中逐个移动目录中的每个文件。
答案 1 :(得分:0)
正如@Arsen所说,试图逐个移动每个文件,
同时检查
**目录模式
**试图移动目录的用户的权限
**否则,可能会尝试以超级用户身份移动目录。
答案 2 :(得分:0)
源目录中的某个文件可能正被另一个进程使用而无法移动。尝试逐个移动每个文件,然后让另一个进程使用一些文件。