Skip to content

Notepad3 holds an exclusive lock for too long on save #5301

@chipplyman

Description

@chipplyman

I have a process with a FileSystemWatcher that immediately reads an xml file when it changes on disk.

If I open and save that file in notepad3 (6.23.203.2), my process throws an exception:

IOException: The process cannot access the file 'c:\path\to\myfile.xml' because it is being used by another process.
      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, Boolean useLongPath, Boolean checkHost)
      at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
      at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
      at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
      at System.Xml.XmlTextReaderImpl.FinishInitUriString()
      at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
      at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions