diff --git a/PKHeX.Core/Saves/Util/BoxUtil.cs b/PKHeX.Core/Saves/Util/BoxUtil.cs
index d803fd996..b72e35ff7 100644
--- a/PKHeX.Core/Saves/Util/BoxUtil.cs
+++ b/PKHeX.Core/Saves/Util/BoxUtil.cs
@@ -17,15 +17,14 @@ public static class BoxUtil
///
/// that is being dumped from.
/// Folder to store files.
- /// Result message from the method.
/// Option to save in child folders with the Box Name as the folder name.
- ///
- public static bool DumpBoxes(this SaveFile SAV, string path, out string result, bool boxFolders = false)
+ /// -1 if aborted, otherwise the amount of files dumped.
+ public static int DumpBoxes(this SaveFile SAV, string path, bool boxFolders = false)
{
- var boxdata = SAV.BoxData;
- if (boxdata == null)
- { result = MsgSaveBoxExportInvalid; return false; }
+ if (!SAV.HasBox)
+ return -1;
+ var boxdata = SAV.BoxData;
int ctr = 0;
foreach (PKM pk in boxdata)
{
@@ -43,9 +42,7 @@ public static bool DumpBoxes(this SaveFile SAV, string path, out string result,
if (!File.Exists(Path.Combine(Path.Combine(path, boxfolder), fileName)))
File.WriteAllBytes(Path.Combine(Path.Combine(path, boxfolder), fileName), pk.DecryptedBoxData);
}
-
- result = string.Format(MsgSaveBoxExportPathCount, ctr) + Environment.NewLine + path;
- return true;
+ return ctr;
}
///
@@ -53,15 +50,14 @@ public static bool DumpBoxes(this SaveFile SAV, string path, out string result,
///
/// that is being dumped from.
/// Folder to store files.
- /// Result message from the method.
/// Box contents to be dumped.
- ///
- public static bool DumpBox(this SaveFile SAV, string path, out string result, int currentBox)
+ /// -1 if aborted, otherwise the amount of files dumped.
+ public static int DumpBox(this SaveFile SAV, string path, int currentBox)
{
- var boxdata = SAV.BoxData;
- if (boxdata == null)
- { result = MsgSaveBoxExportInvalid; return false; }
+ if (!SAV.HasBox)
+ return -1;
+ var boxdata = SAV.BoxData;
int ctr = 0;
foreach (PKM pk in boxdata)
{
@@ -73,9 +69,7 @@ public static bool DumpBox(this SaveFile SAV, string path, out string result, in
if (!File.Exists(Path.Combine(path, fileName)))
File.WriteAllBytes(Path.Combine(path, fileName), pk.DecryptedBoxData);
}
-
- result = string.Format(MsgSaveBoxExportPathCount, ctr) + Environment.NewLine + path;
- return true;
+ return ctr;
}
///
diff --git a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
index 312d21dab..9c7e41775 100644
--- a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
+++ b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
@@ -814,7 +814,11 @@ public bool DumpBoxes(out string result, string path = null, bool separate = fal
Directory.CreateDirectory(path);
- SAV.DumpBoxes(path, out result, separate);
+ var count = SAV.DumpBoxes(path, separate);
+ if (count < 0)
+ result = MsgSaveBoxExportInvalid;
+ else
+ result = string.Format(MsgSaveBoxExportPathCount, count) + Environment.NewLine + path;
return true;
}
@@ -828,7 +832,11 @@ public bool DumpBox(out string result, string path = null)
Directory.CreateDirectory(path);
- SAV.DumpBox(path, out result, Box.CurrentBox);
+ var count = SAV.DumpBox(path, Box.CurrentBox);
+ if (count < 0)
+ result = MsgSaveBoxExportInvalid;
+ else
+ result = string.Format(MsgSaveBoxExportPathCount, count) + Environment.NewLine + path;
return true;
}