Handle ArgumentException from FileSystemWatcher if path is invalid

* Most likely caused by paths that the class chokes on, like
  \\?\UNC\foo\bar type paths.
This commit is contained in:
baldurk
2017-02-06 12:35:21 +00:00
parent 6b776578b9
commit baf2c9fa90
+13 -6
View File
@@ -602,12 +602,19 @@ namespace renderdocui.Code
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>();