Overwrite backup and handle exceptions

This commit is contained in:
yesseruser 2024-12-13 17:45:56 +01:00
parent cfece3f1b9
commit 1d78178fb2
No known key found for this signature in database
GPG Key ID: 8807107EC4046EAF

View File

@ -48,8 +48,16 @@ namespace Bloxstrap
if (!String.IsNullOrEmpty(message)) if (!String.IsNullOrEmpty(message))
Frontend.ShowMessageBox($"{message}\n\n{ex.Message}", System.Windows.MessageBoxImage.Warning); Frontend.ShowMessageBox($"{message}\n\n{ex.Message}", System.Windows.MessageBoxImage.Warning);
try
{
// Create a backup of loaded file // Create a backup of loaded file
File.Copy(FileLocation, FileLocation + ".bak"); File.Copy(FileLocation, FileLocation + ".bak", true);
}
catch (Exception copyEx)
{
App.Logger.WriteLine(LOG_IDENT, $"Failed to create backup file: {FileLocation}.bak");
App.Logger.WriteException(LOG_IDENT, copyEx);
}
} }
Save(); Save();