[BUG] Resolve network root sometimes not working with WARN ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'length') #129

This commit is contained in:
Markus Hofknecht 2020-09-26 15:54:24 +02:00
parent cbdef123ba
commit 49c6ef05f0
5 changed files with 931 additions and 903 deletions

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
<Identity
Name="49543SystemTrayMenu.SystemTrayMenu"
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
Version="1.0.15.0" />
Version="1.0.16.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.16.0")]
[assembly: AssemblyFileVersion("1.0.16.0")]
[assembly: AssemblyVersion("1.0.16.1")]
[assembly: AssemblyFileVersion("1.0.16.1")]

View file

@ -62,15 +62,26 @@ namespace SystemTrayMenu.Utilities
bool isDirectoryToHide = false;
if (path.Length < 260)
{
FileAttributes attributes = File.GetAttributes(path);
hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
bool systemEntry = attributes.HasFlag(
FileAttributes.Hidden | FileAttributes.System);
if ((hideHiddenEntries && hiddenEntry) ||
(hideSystemEntries && systemEntry))
try
{
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;

View file

@ -5,6 +5,7 @@
namespace SystemTrayMenu.Utilities
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@ -15,6 +16,8 @@ namespace SystemTrayMenu.Utilities
internal static class Log
{
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()
{
@ -23,12 +26,21 @@ namespace SystemTrayMenu.Utilities
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)
{
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)