【问题标题】:File being used by another process while reading config.xml from Skype从 Skype 读取 config.xml 时另一个进程正在使用文件
【发布时间】:2017-11-02 08:59:10
【问题描述】:
[ 10,13136] 2017-10-23T11:53:31 - -------------------- IOException caught --------------------
[ 10,13136] 2017-10-23T11:53:31 - The process cannot access the file 'C:\Users\cdahal\AppData\Roaming\Skype\chetan.d\config.xml' because it is being used by another process.
[ 10,13136] 2017-10-23T11:53:31 - Stack trace is : 
[ 10,13136] 2017-10-23T11:53:31 -    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, Int32 bufferSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)

每次更新 Skype 中的辅助功能选项时,它都会更改其 config.xml 文件。我们目前从节点 /config/UI/General/Accessibility 读取值,但是当我的应用程序和 Skype 都在运行并且我对 Accessibility 选项进行更改时,我收到以下错误消息:-

【问题讨论】:

  • 所以您正在尝试更新 Skype 配置,同时它正在运行并且对它锁定其配置文件感到惊讶?
  • 您的问题是什么?简而言之,如果 Skype 已打开并锁定文件,则您无法修改它。
  • 好吧,我正在尝试读取更新后的值。可能的解决方案是将 config.xml 文件复制到临时位置并尝试访问。想知道是否还有其他解决方案..
  • 您这里没有代码 - 您如何打开文件来读取值?
  • 您在打开文件时是否使用了 FileShare.Read 和 FIleAccess.Read?发布您的文件打开代码!

标签: c# .net xml


【解决方案1】:

你没有说出来,但我推断你正在使用 XmlDocument.Load 来加载文件。您应该尝试从使用 FileAccess.Read 和 FileShare.Read 打开的流中加载文档。这是c# xml.Load() locking file on disk causing errors 的副本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多