Permalink
Browse files

Handle ArgumentException from FileSystemWatcher if path is invalid

* Most likely caused by paths that the class chokes on, like
  \\?\UNC\foo\bar type paths.
  • Loading branch information...
1 parent 6b77657 commit baf2c9fa90a04db3d05e7266955961cf0aeb5a4d @baldurk committed Feb 6, 2017
Showing with 13 additions and 6 deletions.
  1. +13 −6 renderdocui/Code/Core.cs
@@ -602,12 +602,19 @@ public void LoadLogfile(string logFile, string origFilename, bool temporary, boo
if (local)
{
- m_LogWatcher = new FileSystemWatcher(Path.GetDirectoryName(m_LogFile), Path.GetFileName(m_LogFile));
- m_LogWatcher.EnableRaisingEvents = true;
- m_LogWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite;
- m_LogWatcher.Created += new FileSystemEventHandler(OnLogfileChanged);
- m_LogWatcher.Changed += new FileSystemEventHandler(OnLogfileChanged);
- m_LogWatcher.SynchronizingObject = m_MainWindow; // callbacks on UI thread please
+ try
+ {
+ m_LogWatcher = new FileSystemWatcher(Path.GetDirectoryName(m_LogFile), Path.GetFileName(m_LogFile));
+ m_LogWatcher.EnableRaisingEvents = true;
+ m_LogWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite;
+ m_LogWatcher.Created += new FileSystemEventHandler(OnLogfileChanged);
+ m_LogWatcher.Changed += new FileSystemEventHandler(OnLogfileChanged);
+ m_LogWatcher.SynchronizingObject = m_MainWindow; // callbacks on UI thread please
+ }
+ catch (ArgumentException)
+ {
+ // likely an "invalid" directory name - FileSystemWatcher doesn't support UNC paths properly
+ }
}
List<ILogViewerForm> logviewers = new List<ILogViewerForm>();

0 comments on commit baf2c9f

Please sign in to comment.