[Feature] Select root folder by windows context menu (#195), version 1.0.19.0

This commit is contained in:
Markus Hofknecht 2021-09-28 21:52:46 +02:00
parent 99fb5a0c08
commit e921e1dc7e
3 changed files with 29 additions and 8 deletions

View file

@ -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))

View file

@ -9,7 +9,7 @@
<Identity
Name="49543SystemTrayMenu.SystemTrayMenu"
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
Version="1.0.17.0" />
Version="1.0.19.0" />
<Properties>
<DisplayName>SystemTrayMenu</DisplayName>

View file

@ -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")]