Add error message if user moves file for backup

This commit is contained in:
Kurt
2022-02-23 21:53:01 -08:00
parent 65130a9ae1
commit bdbd9fc899
2 changed files with 15 additions and 1 deletions

View File

@@ -136,6 +136,7 @@ public static class MessageStrings
public static string MsgSaveSlotBadData { get; set; } = "Unable to set to this slot.";
public static string MsgSaveBackup { get; set; } = "Saved Backup of current SAV to:";
public static string MsgSaveBackupNotFound { get; set; } = "Original file has been moved; unable to copy a backup.";
public static string MsgSaveCurrentGeneration { get; set; } = "Current SAV Generation: {0}";
public static string MsgSaveBoxCloneFromTabs { get; set; } = "Clone Pokemon from Editing Tabs to all slots in {0}?";

View File

@@ -783,11 +783,24 @@ public bool ExportBackup()
{
if (!SAV.State.Exportable || SAV.Metadata.FilePath is not { } file)
return false;
using var sfd = new SaveFileDialog {FileName = Util.CleanFileName(SAV.Metadata.BAKName)};
if (!File.Exists(file))
{
WinFormsUtil.Error(MsgSaveBackupNotFound, file);
return false;
}
var suggestion = Util.CleanFileName(SAV.Metadata.BAKName);
using var sfd = new SaveFileDialog {FileName = suggestion};
if (sfd.ShowDialog() != DialogResult.OK)
return false;
string path = sfd.FileName;
if (!File.Exists(file)) // did they move it again?
{
WinFormsUtil.Error(MsgSaveBackupNotFound, file);
return false;
}
File.Copy(file, path);
WinFormsUtil.Alert(MsgSaveBackup, path);