簡體   English   中英

File.Delete無法刪除文件,因為它正在被另一個進程使用

[英]File.Delete cannot delete a file because it is being used by another process

覆蓋文件時出現錯誤。 如果仍在工作,則無法找到關閉文件的方式。 有人能幫助我嗎 ?

        if (System.IO.File.Exists(Server.MapPath("/html/" + htmlname)))
        {
            System.IO.File.Delete(Server.MapPath("/html/" + htmlname));

            System.IO.File.WriteAllText(Server.MapPath("/html/" + htmlname), mailbody);

        }
        else
        {
            System.IO.File.WriteAllText(Server.MapPath("/html/" + htmlname), mailbody);
        }

摘自msdn.com,它表示:“指定的文件正在使用中。-或者-文件上有一個打開的句柄,並且操作系統是Windows XP或更早的版本。此打開的句柄可能由枚舉目錄和文件引起。有關更多信息,請參見如何:枚舉目錄和文件。

看一下這個: http : //msdn.microsoft.com/en-us/library/system.io.file.delete.aspx

從長遠來看,您也可以自己進行一些搜索。

最好的祝福。

暫無
暫無

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

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