mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-02 10:34:42 +12:00
[BUG] Resolve network root sometimes not working with WARN ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'length') #129
This commit is contained in:
parent
cbdef123ba
commit
49c6ef05f0
1787
Business/Menus.cs
1787
Business/Menus.cs
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,7 @@
|
||||||
<Identity
|
<Identity
|
||||||
Name="49543SystemTrayMenu.SystemTrayMenu"
|
Name="49543SystemTrayMenu.SystemTrayMenu"
|
||||||
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
|
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
|
||||||
Version="1.0.15.0" />
|
Version="1.0.16.0" />
|
||||||
|
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>SystemTrayMenu</DisplayName>
|
<DisplayName>SystemTrayMenu</DisplayName>
|
||||||
|
|
|
@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.16.0")]
|
[assembly: AssemblyVersion("1.0.16.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.16.0")]
|
[assembly: AssemblyFileVersion("1.0.16.1")]
|
||||||
|
|
|
@ -62,15 +62,26 @@ namespace SystemTrayMenu.Utilities
|
||||||
bool isDirectoryToHide = false;
|
bool isDirectoryToHide = false;
|
||||||
if (path.Length < 260)
|
if (path.Length < 260)
|
||||||
{
|
{
|
||||||
FileAttributes attributes = File.GetAttributes(path);
|
try
|
||||||
hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
|
||||||
bool systemEntry = attributes.HasFlag(
|
|
||||||
FileAttributes.Hidden | FileAttributes.System);
|
|
||||||
if ((hideHiddenEntries && hiddenEntry) ||
|
|
||||||
(hideSystemEntries && systemEntry))
|
|
||||||
{
|
{
|
||||||
isDirectoryToHide = true;
|
FileAttributes attributes = File.GetAttributes(path);
|
||||||
|
hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
||||||
|
bool systemEntry = attributes.HasFlag(
|
||||||
|
FileAttributes.Hidden | FileAttributes.System);
|
||||||
|
if ((hideHiddenEntries && hiddenEntry) ||
|
||||||
|
(hideSystemEntries && systemEntry))
|
||||||
|
{
|
||||||
|
isDirectoryToHide = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
Log.Warn($"path:'{path}'", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Info($"path too long (>=260):'{path}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
return isDirectoryToHide;
|
return isDirectoryToHide;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
namespace SystemTrayMenu.Utilities
|
namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -15,6 +16,8 @@ namespace SystemTrayMenu.Utilities
|
||||||
internal static class Log
|
internal static class Log
|
||||||
{
|
{
|
||||||
private static readonly Logger LogValue = new Logger(string.Empty);
|
private static readonly Logger LogValue = new Logger(string.Empty);
|
||||||
|
private static List<string> warnings = new List<string>();
|
||||||
|
private static List<string> infos = new List<string>();
|
||||||
|
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
|
@ -23,12 +26,21 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
internal static void Info(string message)
|
internal static void Info(string message)
|
||||||
{
|
{
|
||||||
LogValue.Info(message);
|
if (!infos.Contains(message))
|
||||||
|
{
|
||||||
|
LogValue.Info(message);
|
||||||
|
infos.Add(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Warn(string message, Exception ex)
|
internal static void Warn(string message, Exception ex)
|
||||||
{
|
{
|
||||||
LogValue.Warn($"{message}{Environment.NewLine}{ex}");
|
string warning = $"{message} {ex.ToString().Replace(Environment.NewLine, " ", StringComparison.InvariantCulture)}";
|
||||||
|
if (!warnings.Contains(warning))
|
||||||
|
{
|
||||||
|
LogValue.Warn(warning);
|
||||||
|
warnings.Add(warning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Error(string message, Exception ex)
|
internal static void Error(string message, Exception ex)
|
||||||
|
|
Loading…
Reference in a new issue