Add save detection exception handling

Yay for jksv allowing invalid filenames
This commit is contained in:
Kurt 2016-12-03 09:32:18 -08:00
parent 247864ce8f
commit 3a377f9198

View file

@ -463,8 +463,18 @@ namespace PKHeX
{ {
if (!Directory.Exists(folderPath)) if (!Directory.Exists(folderPath))
return null; return null;
return Directory.GetFiles(folderPath, "*", deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly) string[] files = new string[0];
.Where(f => SizeValidSAV((int)new FileInfo(f).Length)); try
{
var searchOption = deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
files = Directory.GetFiles(folderPath, "*", searchOption);
}
catch (ArgumentException)
{
Util.Error("Error encountered when detecting saves in the following folder:" + Environment.NewLine + folderPath,
"Advise manually scanning to remove bad filenames from the folder." + Environment.NewLine + "Likely caused via Homebrew creating invalid filenames.");
}
return files.Where(f => SizeValidSAV((int)new FileInfo(f).Length));
} }
/// <summary> /// <summary>