diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs index cb7ff1935..e20e89003 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs @@ -1,10 +1,13 @@ -// Copyright (c) Microsoft Corporation +// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using Wox.Infrastructure.Storage; +using Wox.Plugin.Logger; namespace Microsoft.Plugin.Program.Storage { @@ -33,7 +36,18 @@ namespace Microsoft.Plugin.Program.Storage Environment.GetFolderPath(Environment.SpecialFolder.Desktop), Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory), }; - return paths; + + var invalidPaths = new List(); + foreach (var path in paths) + { + if (!Directory.Exists(path)) + { + Log.Warn($"Directory {path} does not exist and will be ignored", typeof(Win32ProgramFileSystemWatchers)); + invalidPaths.Add(path); + } + } + + return paths.Except(invalidPaths).ToArray(); } // Initializes the FileSystemWatchers