From baf2c9fa90a04db3d05e7266955961cf0aeb5a4d Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 6 Feb 2017 12:35:21 +0000 Subject: [PATCH] Handle ArgumentException from FileSystemWatcher if path is invalid * Most likely caused by paths that the class chokes on, like \\?\UNC\foo\bar type paths. --- renderdocui/Code/Core.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/renderdocui/Code/Core.cs b/renderdocui/Code/Core.cs index a23de027e..5de234d0a 100644 --- a/renderdocui/Code/Core.cs +++ b/renderdocui/Code/Core.cs @@ -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 logviewers = new List();