If the icon URL is already an ico file, just use it directly

This commit is contained in:
Paul Betts
2014-08-27 16:55:34 -07:00
parent 348c5013a8
commit 169d91b8ac

View File

@@ -108,10 +108,17 @@ namespace Squirrel
var wc = new WebClient();
await wc.DownloadFileTaskAsync(zp.IconUrl, targetPng);
using (var fs = new FileStream(targetIco, FileMode.Create))
using (var bmp = (Bitmap)Image.FromFile(targetPng))
using (var ico = Icon.FromHandle(bmp.GetHicon())) {
ico.Save(fs);
using (var fs = new FileStream(targetIco, FileMode.Create)) {
if (zp.IconUrl.AbsolutePath.EndsWith("ico")) {
var bytes = File.ReadAllBytes(targetPng);
fs.Write(bytes, 0, bytes.Length);
} else {
using (var bmp = (Bitmap)Image.FromFile(targetPng))
using (var ico = Icon.FromHandle(bmp.GetHicon())) {
ico.Save(fs);
}
}
key.SetValue("DisplayIcon", targetIco, RegistryValueKind.String);
}
} catch(Exception ex) {