![](/img/trans.png)
[英]File.Delete cannot delete a file because it is being used by another process. Not sure how to fix this
[英]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.