Esempio n. 1
0
        public static bool ExtractMainIconFromFile(string exePath, string outPath)
        {
            try
            {
                var extractor = new IconExtractor(exePath);
                if (extractor.Count == 0)
                {
                    return(false);
                }

                var ico = extractor.GetIcon(0);
                try
                {
                    FileSystem.PrepareSaveFile(outPath);
                    using (var fs = File.OpenWrite(outPath))
                    {
                        ico.Save(fs);
                    }

                    return(true);
                }
                finally
                {
                    ico.Dispose();
                }
            }
            catch (Exception e)// when (false)
            {
                logger.Error(e, $"Failed to extract icon from {exePath}.");
                return(false);
            }
        }
Esempio n. 2
0
        public static bool ExtractMainIconFromFile(string exePath, Stream outStream)
        {
            try
            {
                var extractor = new IconExtractor(exePath);
                if (extractor.Count == 0)
                {
                    return(false);
                }

                var ico = extractor.GetIcon(0);
                try
                {
                    ico.Save(outStream);
                    return(true);
                }
                finally
                {
                    ico.Dispose();
                }
            }
            catch (Exception e)// when (false)
            {
                logger.Error(e, $"Failed to extract icon from {exePath}.");
                return(false);
            }
        }
Esempio n. 3
0
        public static Icon ExtractMainIconFromFile(string exePath)
        {
            try
            {
                var extractor = new IconExtractor(exePath);
                if (extractor.Count == 0)
                {
                    return(null);
                }

                return(extractor.GetIcon(0));
            }
            catch (Exception e)// when (false)
            {
                logger.Error(e, $"Failed to extract icon from {exePath}.");
                return(null);
            }
        }