2013-04-17 49 views
1

當我試圖剪切和粘貼目錄(子文件夾和文件),它給了我錯誤訪問路徑被拒絕。有時它會在我將任何文件上傳到該目錄時發揮作用,然後顯示錯誤。訪問路徑被拒絕移動使用c目錄#

我可以完全訪問該目錄和子目錄。 我能夠刪除和上傳該目錄下的文件,但無法將該目錄移動到任何其他位置。

我曾嘗試:

  1. 網絡服務,每個人都完全訪問。
  2. 更新應用程序池的標識。

我也試過這種

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

請顯示您的代碼。 – Blorgbeard

+1

錯誤來自生產或本地主機? – Gajendra

+0

您是否嘗試模擬爲IIS用戶http://technet.microsoft.com/zh-cn/library/cc730708(v=WS.10).aspx –

回答

0

「源」目錄中的某個文件可能正在使用中,並且無法移動。嘗試在循環中逐個移動目錄中的每個文件。

0

爲@Arsen說,一個一個試移動的每個文件,,

同時檢查

**目錄

**的用戶權限誰嘗試的模式移動目錄

**否則,可能會嘗試以超級用戶的身份移動目錄。

0

可能的是,在源目錄中的文件中的一個被另一個進程使用,並且不能移動。嘗試逐個移動每個文件,然後獲得一些正在被另一個進程使用的文件。

+0

感謝您的幫助,它適用於我 –