简体   繁体   English

File.Delete无法删除文件,因为它正在被另一个进程使用

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

I'm getting error when I'm overwriting the file. 覆盖文件时出现错误。 And if it is still working can't find to way for close file. 如果仍在工作,则无法找到关闭文件的方式。 Can someone help me please ? 有人能帮助我吗 ?

        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);
        }

Taken from msdn.com which is saying that : "The specified file is in use. -or- There is an open handle on the file, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files." 摘自msdn.com,它表示:“指定的文件正在使用中。-或者-文件上有一个打开的句柄,并且操作系统是Windows XP或更早的版本。此打开的句柄可能由枚举目录和文件引起。有关更多信息,请参见如何:枚举目录和文件。

take a look a this : http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx 看一下这个: http : //msdn.microsoft.com/en-us/library/system.io.file.delete.aspx

Also doing some search on your own will prove to be efficient on the long run. 从长远来看,您也可以自己进行一些搜索。

Best regards. 最好的祝福。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 File.Delete无法删除文件,因为它正在被另一个进程使用。 不确定如何解决此问题 - File.Delete cannot delete a file because it is being used by another process. Not sure how to fix this File.Delete进程无法访问文件,因为它正在被另一个进程使用 - File.Delete the process cannot access the file because it is being used by another process File.Delete错误“该进程无法访问该文件,因为该文件正在被另一个进程使用” - File.Delete error “The process cannot access the file because it is being used by another process” File.Delete被另一个进程使用 - File.Delete being used by another process C# File.Delete,另一个进程正在使用的文件 - C# File.Delete, file being used by another process 位图上的File.Delete不起作用,因为该文件正在被另一个进程使用(我使用了bitmap.Dispose();) - File.Delete on bitmap doesn't work because the file is being used by another process (I used bitmap.Dispose();) 无法删除文件,因为它正被另一个进程使用 - cannot delete file because it's being used by another process 无法删除文件,因为它正由另一个进程使用 - Cannot delete file because it is being used by another process System.IO.File.Delete 抛出“该进程无法访问该文件,因为它正被另一个进程使用” - System.IO.File.Delete throws "The process cannot access the file because it is being used by another process" “尝试删除文件时,进程无法访问该文件,因为它正被另一个进程使用” - “the process cannot access the file because it is being used by another process” when trying to delete file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM