从Skype读取config.xml时,另一个进程正在使用该文件

时间:2017-11-02 08:59:11

标签: c# .net xml

[ 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文件。我们当前从node / config / UI / General / Accessibility中读取值,但是当我的应用程序和skype都在运行并且我对Accessibility选项进行了更改时,我收到以下错误消息: -

1 个答案:

答案 0 :(得分:0)

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