Skip to content
This repository was archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Should fix bug with non existent files.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonBlade committed Oct 19, 2019
1 parent 4825c9b commit a402570
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions PaisleyPark/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,20 @@ public static void Save(Settings settings)
// Get the full path to the settings file.
var fullPath = Path.Combine(SETTINGS_FOLDER, SETTINGS_FILE);

// Store three backups
File.Copy(fullPath + "2.bak", fullPath + "3.bak");
File.Copy(fullPath + "1.bak", fullPath + "2.bak");
File.Copy(fullPath, fullPath + "1.bak");
try
{
// Store three backups
if (File.Exists(fullPath + "2.bak"))
File.Copy(fullPath + "2.bak", fullPath + "3.bak");
if (!File.Exists(fullPath + "1.bak"))
File.Copy(fullPath + "1.bak", fullPath + "2.bak");
File.Copy(fullPath, fullPath + "1.bak");
}
catch (Exception ex)
{
logger.Error(ex, "Couldn't create backups.");
MessageBox.Show("Couldn't create save backups.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Warning);
}

// Create StreamWriter instance to save file contents into full path.
using (var text = File.CreateText(fullPath))
Expand Down

0 comments on commit a402570

Please sign in to comment.