Always create a new file when writing to disk.

This commit is contained in:
Frederik Carlier
2016-06-03 16:01:48 +02:00
parent 6571783fab
commit bf031fadab

View File

@@ -219,7 +219,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);
}