Notepad3 icon indicating copy to clipboard operation
Notepad3 copied to clipboard

Notepad3 holds an exclusive lock for too long on save

Open chipplyman opened this issue 1 year ago • 0 comments

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)

chipplyman avatar Sep 26 '24 00:09 chipplyman