public static bool MatchImages(string[] images, Dictionary <string, Classes.Region> imageRegion, string romName, out string imageFoundPath) { imageFoundPath = string.Empty; bool found = false; string romTrimmed = RomFunctions.TrimRomName(romName); var romRegion = RomFunctions.DetectRegion(romName); foreach (var image in images) { string imageTrimmed = RomFunctions.TrimRomName(image); if (imageTrimmed == romTrimmed && imageRegion[RomFunctions.GetFileName(image)] == romRegion) { found = true; imageFoundPath = image; break; } } if (!found) { foreach (var image in images) { string imageTrimmed = RomFunctions.TrimRomName(image); if (imageTrimmed == romTrimmed) { found = true; imageFoundPath = image; break; } } } return(found); }