c# - System.IO.Exception 错误 : "The requested operation cannot be performed on a file with a user-mapped section open."

标签 c# xml ioexception

我在写入 XML 文件时收到一个非常奇怪的 IOException:

System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)
   at System.Xml.XmlDocument.Save(String filename)

错误发生在我调用XmlDocument的Save(string)函数时。

对发生的事情有什么想法吗?

最佳答案

看起来另一个进程使用文件映射(共享内存)API 打开了文件。

Process Explorer 中的查找功能应该可以告诉您。

关于c# - System.IO.Exception 错误 : "The requested operation cannot be performed on a file with a user-mapped section open.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1302698/

相关文章:

c# - Web API 返回 XML

java - 为什么选择 XML 而不是 Log4J 配置的属性文件?

javascript - 在E4X中过滤2个不同的节点?

java.io.IOException :Bogus chunk size 异常

java - 向 treeMap 的函数添加值而不丢失旧数据

c# - C# dll 参数中的 pythonnet

c# - 通过在控件上单击并拖动来移动窗口

c# - 如何使用 aspnet ApiVersioning 在 Swashbuckle 中配置 MultipleApiVersions

JavaFX 允许用户仅编辑文本的某些区域

c# - 系统.IO.IOException : Cannot close stream until all bytes are written