check if directory exists

This commit is contained in:
Davide 2021-11-25 20:59:21 +01:00
parent 47b5386c0c
commit 60f6418720

View file

@ -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<string>();
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