convert personclass writer to xml document so we can encrypt.

This commit is contained in:
Tim Young 2017-08-09 16:03:19 -05:00
parent 490a8d1b04
commit e4edd9bf5a
2 changed files with 16 additions and 12 deletions

View File

@ -182,17 +182,23 @@ namespace EduNetworkBuilder
settings.NewLineOnAttributes = true; settings.NewLineOnAttributes = true;
if (doRotation && File.Exists(filename)) if (doRotation && File.Exists(filename))
NB.MoveFileWithRotation(filename); //make a backup of the file NB.MoveFileWithRotation(filename); //make a backup of the file
XmlWriter writer = XmlWriter.Create(filename, settings);
//Now we write the file: //Generate a doc that has a writer attached. All the normal save funcs work with the writer,
writer.WriteStartDocument(); //But, we can encrypt the XmlDocument
writer.WriteStartElement("EduNetworkBuilderUser"); XmlDocument doc = new XmlDocument();
writer.WriteComment("This is a user file for EduNetworkBuilder."); using (XmlWriter writer = doc.CreateNavigator().AppendChild())
Save(writer); {
writer.WriteEndElement(); //XmlWriter writer = XmlWriter.Create(filename, settings);
writer.WriteEndDocument();
writer.Flush(); //Now we write the file:
writer.Close(); writer.WriteStartDocument();
writer.WriteStartElement("EduNetworkBuilderUser");
writer.WriteComment("This is a user file for EduNetworkBuilder.");
Save(writer);
writer.WriteEndElement();
writer.WriteEndDocument();
}
doc.Save(filename);
} }

View File

@ -140,8 +140,6 @@ namespace EduNetworkBuilder
//The decryption failed. //The decryption failed.
throw new LoginException("Key/Salt unable to decrypt."); throw new LoginException("Key/Salt unable to decrypt.");
} }
} }
protected static string GenCharString(Random RanGen, int length) protected static string GenCharString(Random RanGen, int length)