From fa6fae3aa313d8d857c7ec8ce54d82ff4123d8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20Kentt=C3=A4?= Date: Thu, 13 Jun 2024 13:15:53 +0300 Subject: [PATCH] Catch errors in writing image --- src/Setup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Setup.cs b/src/Setup.cs index e8b350e..57a2d84 100644 --- a/src/Setup.cs +++ b/src/Setup.cs @@ -339,8 +339,12 @@ public class Setup { g.DrawImageUnscaledAndClipped(img, new Rectangle(Point.Empty, img.Size)); } try { - bmp.Save(newName, ImageFormat.Bmp); - } catch { + var ms = new MemoryStream(); + bmp.Save(ms, ImageFormat.Bmp); + var bytes = ms.ToArray(); + File.WriteAllBytes(newName, bytes); + } catch (Exception e) { + Log($"InstallImageFile failed: {e.ToString()}"); throw new SetupException($"Failed to install image {name} to {newName}."); } }