This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
// Extract the icon as png to avoid quality loss, convert it back by using something like GIMP or so ... | |
var outputFile = new FileInfo("YourIconName.png"); | |
using var icon = Icon.ExtractIcon(@"THE_FULL_PATH_TO_YOUR_EXE_FILE", 0, 48); // tweak the index parameter and desired extraction size if applicable | |
using var bitmap = icon.ToBitmap(); // convert to bitmap due to icon.Save(...) having quality issues! | |
using var fs = outputFile.OpenWrite(); |