Fixed crash when trying to load random roms when folder no longer exists

This commit is contained in:
Souryo 2017-01-15 14:28:51 -05:00
parent d968541444
commit 535a2e45f0

View File

@ -1620,9 +1620,11 @@ namespace Mesen.GUI.Forms
List<string> gameRoms = new List<string>();
foreach(string folder in gameFolders) {
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.nes", SearchOption.TopDirectoryOnly));
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.unf", SearchOption.TopDirectoryOnly));
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.fds", SearchOption.TopDirectoryOnly));
if(Directory.Exists(folder)) {
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.nes", SearchOption.TopDirectoryOnly));
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.unf", SearchOption.TopDirectoryOnly));
gameRoms.AddRange(Directory.EnumerateFiles(folder, "*.fds", SearchOption.TopDirectoryOnly));
}
}
if(gameRoms.Count == 0) {