diff --git a/PKHeX.Core/Saves/SaveUtil.cs b/PKHeX.Core/Saves/SaveUtil.cs
index 4be549940..f8e7c9c84 100644
--- a/PKHeX.Core/Saves/SaveUtil.cs
+++ b/PKHeX.Core/Saves/SaveUtil.cs
@@ -539,7 +539,7 @@ public static SaveFile GetBlankSAV(int generation, string OT)
///
/// Folder to look within
/// Search all subfolders
- /// Full path of all save files that match criteria.
+ /// If this function returns true, full path of all save files that match criteria. If this function returns false, the error message, or null if the directory could not be found
/// Boolean indicating whether or not operation was successful.
public static bool GetSavesFromFolder(string folderPath, bool deep, out IEnumerable result)
{
diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs
index 6df3339db..90ea97c70 100644
--- a/PKHeX.WinForms/MainWindow/Main.cs
+++ b/PKHeX.WinForms/MainWindow/Main.cs
@@ -181,7 +181,7 @@ private void FormLoadInitialFiles(string[] args)
try
{
if (!DetectSaveFile(out string path) && path != null)
- WinFormsUtil.Error(path);
+ WinFormsUtil.Error(path); // `path` contains the error message
if (path != null && File.Exists(path))
OpenQuick(path, force: true);
diff --git a/PKHeX.WinForms/Util/PathUtilWindows.cs b/PKHeX.WinForms/Util/PathUtilWindows.cs
index 9224b4aa4..a77a36011 100644
--- a/PKHeX.WinForms/Util/PathUtilWindows.cs
+++ b/PKHeX.WinForms/Util/PathUtilWindows.cs
@@ -44,7 +44,9 @@ public static string[] Get3DSBackupPaths(string root)
///
/// Detects a save file.
///
- /// Full path of a save file. Returns null if unable to find any.
+ /// If this function returns true, full path of a save file or null if no path could be found. If this function returns false, this parameter will be set to the error message.
+ /// Paths to check in addition to the default paths
+ /// A boolean indicating whether or not a file was detected
public static bool DetectSaveFile(out string path, params string[] extra)
{
string path3DS = Path.GetPathRoot(Get3DSLocation());
@@ -59,10 +61,11 @@ public static bool DetectSaveFile(out string path, params string[] extra)
{
if (!SaveUtil.GetSavesFromFolder(p, true, out IEnumerable files))
{
- if (files == null)
- continue;
- path = files.First(); // error
- return false;
+ if (files != null) // Could be null if `p` doesn't exist
+ {
+ path = string.Concat(Environment.NewLine, files); // `files` contains the error message
+ return false;
+ }
}
possiblePaths.AddRange(files);
}
diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs
index df58c417b..861a3f10f 100644
--- a/PKHeX.WinForms/Util/WinFormsUtil.cs
+++ b/PKHeX.WinForms/Util/WinFormsUtil.cs
@@ -228,8 +228,8 @@ public static bool OpenSAVPKMDialog(string[] Extensions, out string path)
string pathCache = CyberGadgetUtil.GetCacheFolder();
if (Directory.Exists(pathCache))
cgse = Path.Combine(pathCache);
- if (!PathUtilWindows.DetectSaveFile(out path, cgse))
- Error(path);
+ if (!PathUtilWindows.DetectSaveFile(out path, cgse) && !string.IsNullOrEmpty(path))
+ Error(path); // `path` contains the error message
if (path != null)
{ ofd.FileName = path; }