簡體   English   中英

asp.net該進程無法使用File.Copy和File.Delete訪問文件

[英]asp.net The process cannot access the file with File.Copy and File.Delete

我基本上是在使用簡單的File.CopyFile.Delete首先我將文件從一個文件夾復制到另一個文件夾,而不是將File.Delete到Delete from Previous文件夾,但是當編譯器出現在File.Delete ,出現以下錯誤

進程無法使用File.Copy和File.Delete訪問文件

我的代碼是。

  if (!Directory.Exists(copyPath))
            {
                File.Copy(filefullpath, copyPath);
                File.Delete(filefullpath);
            }

雖然它復制文件到copyPath但刪除給出錯誤。

嘗試File.Move

if (!File.Exists(copyPath))
{
     File.Move(filefullpath, copyPath); // Try to move
}

這不是UnauthorizedAccessException異常嗎? 檢查適當的用戶(IIS_IUSRS)在文件夾中是否具有CRUD權限。 File.Move可能導致NTFS權限繼承問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM