mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 16:41:36 -07:00
Create .bak file when loading fails (#3984)
* Create backup on file loading fail When loading a file that has errors in it, Bloxstrap would previously overwrite the file with the defaults. This commit now copies the file to a .bak file with the same name so the user can choose to edit it and fix issues. * Overwrite backup and handle exceptions
This commit is contained in:
parent
1dc31867bb
commit
84822e29c6
@ -47,6 +47,17 @@ namespace Bloxstrap
|
||||
|
||||
if (!String.IsNullOrEmpty(message))
|
||||
Frontend.ShowMessageBox($"{message}\n\n{ex.Message}", System.Windows.MessageBoxImage.Warning);
|
||||
|
||||
try
|
||||
{
|
||||
// Create a backup of loaded file
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user