diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index a9a7a65..299a6ee 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -257,13 +257,13 @@ namespace SystemTrayMenu.DataClasses private bool SetLnk(int level, ref bool isLnkDirectory, ref string resolvedLnkPath) { bool handled = false; - resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath); + resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath, out bool isFolder); if (string.IsNullOrEmpty(resolvedLnkPath)) { // do nothing } - else if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath))) + else if (isFolder) { icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Open, true, true, level == 0, out bool loading); IconLoading = loading; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 51f4b54..4577d99 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.1.0.3")] -[assembly: AssemblyFileVersion("1.1.0.3")] +[assembly: AssemblyVersion("1.1.0.4")] +[assembly: AssemblyFileVersion("1.1.0.4")] diff --git a/Utilities/File/FileLnk.cs b/Utilities/File/FileLnk.cs index 3de1779..c583309 100644 --- a/Utilities/File/FileLnk.cs +++ b/Utilities/File/FileLnk.cs @@ -5,6 +5,7 @@ namespace SystemTrayMenu.Utilities { using System; + using System.Collections.Generic; using System.IO; using System.Net.NetworkInformation; using System.Threading; @@ -12,19 +13,20 @@ namespace SystemTrayMenu.Utilities internal class FileLnk { - public static string GetResolvedFileName(string shortcutFilename) + public static string GetResolvedFileName(string shortcutFilename, out bool isFolder) { + bool isFolderByShell = false; string resolvedFilename = string.Empty; if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) { - resolvedFilename = GetShortcutFileNamePath(shortcutFilename); + resolvedFilename = GetShortcutFileNamePath(shortcutFilename, out isFolderByShell); } else { Thread staThread = new(new ParameterizedThreadStart(StaThreadMethod)); void StaThreadMethod(object obj) { - resolvedFilename = GetShortcutFileNamePath(shortcutFilename); + resolvedFilename = GetShortcutFileNamePath(shortcutFilename, out isFolderByShell); } staThread.SetApartmentState(ApartmentState.STA); @@ -32,6 +34,7 @@ namespace SystemTrayMenu.Utilities staThread.Join(); } + isFolder = isFolderByShell; return resolvedFilename; } @@ -67,9 +70,10 @@ namespace SystemTrayMenu.Utilities return pingable; } - private static string GetShortcutFileNamePath(object shortcutFilename) + private static string GetShortcutFileNamePath(object shortcutFilename, out bool isFolder) { string resolvedFilename = string.Empty; + isFolder = false; string pathOnly = Path.GetDirectoryName((string)shortcutFilename); string filenameOnly = Path.GetFileName((string)shortcutFilename); @@ -81,6 +85,7 @@ namespace SystemTrayMenu.Utilities try { ShellLinkObject link = (ShellLinkObject)folderItem.GetLink; + isFolder = link.Target.IsFolder; if (string.IsNullOrEmpty(link.Path)) { // https://github.com/Hofknecht/SystemTrayMenu/issues/242