Merge pull request #11 from quamotion/fixes/create-new-file

Always create a new file when writing to disk.
This commit is contained in:
2016-06-22 05:10:45 +01:00
committed by GitHub

View File

@@ -214,7 +214,10 @@ namespace Claunia.PropertyList
string parent = outFile.DirectoryName;
if (!Directory.Exists(parent))
Directory.CreateDirectory(parent);
using (Stream fous = outFile.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite))
// Use Create here -- to make sure that when the updated file is shorter than
// the original file, no "obsolete" data is left at the end.
using (Stream fous = outFile.Open(FileMode.Create, FileAccess.ReadWrite))
{
SaveAsXml(root, fous);
}