diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs
index 1398eb4..f7b1047 100644
--- a/EduNetworkBuilder/NB.cs
+++ b/EduNetworkBuilder/NB.cs
@@ -312,6 +312,7 @@ namespace EduNetworkBuilder
public static int DefaultPasswordLen = 6;
public static int DefaultMachinePasswordLen = 20;
public static int DefaultSaltLen = 50;
+ public static int NormalRotation = 5;
public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,.";
public static string AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._";
@@ -1039,6 +1040,16 @@ namespace EduNetworkBuilder
MoveFileWithRotation(SourceFileWithDir, StandardDest, rotation);
}
+ ///
+ /// Move a file out of the way, making a rotating backup at the same time. backup to appdata
+ ///
+ /// A source filename with a directory
+ public static void MoveFileWithRotation(string SourceFileWithDir)
+ {
+ string StandardDest = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EduNetworkBuilder");
+ MoveFileWithRotation(SourceFileWithDir, StandardDest, NB.NormalRotation);
+ }
+
///
/// Given a file, rotate it with the specified number of versions.
///
diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs
index 1b7fb83..5b2fc8b 100644
--- a/EduNetworkBuilder/NetworkBuilder.cs
+++ b/EduNetworkBuilder/NetworkBuilder.cs
@@ -1559,7 +1559,7 @@ namespace EduNetworkBuilder
OurSettings.Save(NB.IsRunningOnMono());
if (CurrentUser != null)
- CurrentUser.Save();
+ CurrentUser.Save(true); //Save the person, making a backup of the person file
}
private void dHCPRequestToolStripMenuItem_Click(object sender, EventArgs e)
diff --git a/EduNetworkBuilder/PersonClass.cs b/EduNetworkBuilder/PersonClass.cs
index 55bf5a7..f4063a7 100644
--- a/EduNetworkBuilder/PersonClass.cs
+++ b/EduNetworkBuilder/PersonClass.cs
@@ -167,18 +167,20 @@ namespace EduNetworkBuilder
}
}
- public void Save()
+ public void Save(bool doRotation = false)
{
//Save to our pre-existing / pre-defined file
string filename = Path.Combine(filepath, FileName);
- Save(filename);
+ Save(filename, doRotation);
}
- public void Save(string filename)
+ public void Save(string filename, bool doRotation = false)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = true;
+ if (doRotation && File.Exists(filename))
+ NB.MoveFileWithRotation(filename); //make a backup of the file
XmlWriter writer = XmlWriter.Create(filename, settings);
//Now we write the file: