示例#1
0
        public static string CustomFileIcon(string fileName)
        {
            if (string.IsNullOrEmpty(fileName) || (appImages == null))
            {
                return(null);
            }

            string imageName = null;

            if (FileOperations.FileIsLink(fileName))
            {
                string tempName = FileOperations.ExtractFileNameFromShellLink(fileName);
                if (!string.IsNullOrEmpty(tempName))
                {
                    fileName = tempName;
                }
            }

            string shortName = Path.GetFileName(fileName);

            imageName = appImages.ReadString("Program", shortName);
            if (!string.IsNullOrEmpty(imageName))
            {
                if (FileOperations.FileExists(imageName))
                {
                    return(imageName);
                }
            }
            return(null);
        }
示例#2
0
        private static Image TryExtractImageFromShellLink(string fileName)
        {
            Bitmap result = null;

            string targetName = FileOperations.ExtractFileNameFromShellLink(fileName);

            if (!string.IsNullOrEmpty(targetName))
            {
                //link uses original target icon
                if (FileOperations.FileIsExe(targetName))
                {
                    result = (Bitmap)ExtractIconFromExecutable(targetName);
                }
            }
            return(result);
        }