Catch errors in writing image

This commit is contained in:
Lauri Kenttä
2024-06-13 13:15:53 +03:00
parent 90fb8e47c1
commit fa6fae3aa3

View File

@@ -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}.");
}
}