rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
5.15k stars 336 forks source link

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

Open chipplyman opened 2 months ago

chipplyman commented 2 months ago

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)