Fix loading of icons if archive file doesn't exist

This commit is contained in:
Pat Hartl 2023-08-28 18:43:36 -05:00
parent b59b0eca0e
commit 1def1ce0e8

View file

@ -121,15 +121,15 @@ namespace LANCommander.Services
else else
{ {
#if WINDOWS #if WINDOWS
if (game.Archives == null || game.Archives.Count == 0)
throw new FileNotFoundException();
var archive = game.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault();
Bitmap bitmap = null;
try try
{ {
if (game.Archives == null || game.Archives.Count == 0)
throw new FileNotFoundException();
var archive = game.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault();
Bitmap bitmap = null;
var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon); var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon);
if (IsWinPEFile(iconReference)) if (IsWinPEFile(iconReference))
@ -156,10 +156,13 @@ namespace LANCommander.Services
return iconPng; return iconPng;
} }
catch (Exception ex) { } catch (Exception ex)
#endif {
}
return File.ReadAllBytes("favicon.png"); return File.ReadAllBytes("favicon.png");
#endif
} }
} }