diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 9d0857a46157..bf5166123957 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -1943,7 +1943,11 @@ await Task.Factory.StartNew(() => private void WatchForWin32FolderChanges(string? folderPath) { - if (Directory.Exists(folderPath)) + if (!Directory.Exists(folderPath)) + return; + + // NOTE: Suppressed NullReferenceException caused by EnableRaisingEvents + SafetyExtensions.IgnoreExceptions(() => { watcher = new FileSystemWatcher { @@ -1956,7 +1960,7 @@ private void WatchForWin32FolderChanges(string? folderPath) watcher.Deleted += DirectoryWatcher_Changed; watcher.Renamed += DirectoryWatcher_Changed; watcher.EnableRaisingEvents = true; - } + }, App.Logger); } private async void DirectoryWatcher_Changed(object sender, FileSystemEventArgs e)