From e921e1dc7e554b03e66623a04b297d62bd9c2de1 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Tue, 28 Sep 2021 21:52:46 +0200 Subject: [PATCH] [Feature] Select root folder by windows context menu (#195), version 1.0.19.0 --- Config/Config.cs | 31 ++++++++++++++++++++++++++----- Packaging/Package.appxmanifest | 2 +- Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Config/Config.cs b/Config/Config.cs index 713afdc..00b0747 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -59,8 +59,7 @@ namespace SystemTrayMenu public static bool LoadOrSetByUser() { - bool pathOK = FileLnk.IsNetworkPath(Path) || - (Directory.Exists(Path) && Directory.GetFiles(Path).Length > 0); + bool pathOK = IsPathOK(Path); if (!pathOK) { @@ -88,9 +87,7 @@ namespace SystemTrayMenu { if (dialog.ShowDialog() == DialogResult.OK) { - if (FileLnk.IsNetworkPath(Path) || - (Directory.Exists(dialog.Folder) && - Directory.GetFiles(Path).Length > 0)) + if (IsPathOK(dialog.Folder)) { pathOK = true; Settings.Default.PathDirectory = @@ -112,6 +109,30 @@ namespace SystemTrayMenu return pathOK; } + private static bool IsPathOK(string path) + { + bool isPathOK = false; + + bool folderContainsFiles = false; + try + { + folderContainsFiles = Directory.GetFiles(path).Length > 0; + } + catch (UnauthorizedAccessException ex) + { + Log.Warn($"path:'{path}'", ex); + } + catch (IOException ex) + { + Log.Warn($"path:'{path}'", ex); + } + + isPathOK = FileLnk.IsNetworkPath(path) || + (Directory.Exists(path) && folderContainsFiles); + + return isPathOK; + } + internal static void ShowHelpFAQ() { if (FileUrl.GetDefaultBrowserPath(out string browserPath)) diff --git a/Packaging/Package.appxmanifest b/Packaging/Package.appxmanifest index 95c84c5..9c93668 100644 --- a/Packaging/Package.appxmanifest +++ b/Packaging/Package.appxmanifest @@ -9,7 +9,7 @@ + Version="1.0.19.0" /> SystemTrayMenu diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 6b6602e..ca7b863 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.18.4")] -[assembly: AssemblyFileVersion("1.0.18.4")] +[assembly: AssemblyVersion("1.0.19.0")] +[assembly: AssemblyFileVersion("1.0.19.0")]