From 225f10d1a097d48ff83fcc72ce0a493134f2fc66 Mon Sep 17 00:00:00 2001 From: Simon G Date: Wed, 11 Nov 2020 16:18:10 +0100 Subject: [PATCH] #25: return true if file isn't empty, think if bool return value makes sense here --- GBase/DataHandling/XmlDataWriter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GBase/DataHandling/XmlDataWriter.cs b/GBase/DataHandling/XmlDataWriter.cs index 4dce15d..31cfc74 100644 --- a/GBase/DataHandling/XmlDataWriter.cs +++ b/GBase/DataHandling/XmlDataWriter.cs @@ -31,7 +31,7 @@ namespace GBase.DataHandling { //if the xml file isn't empty, return if (file.Length > 3) //> 3 because of BOM - return false; + return true; //TODO: Don't return bool? XDocument xmlDocument = new XDocument(); xmlDocument.Add(new XElement(rootElementName)); @@ -74,6 +74,7 @@ namespace GBase.DataHandling if (typeName == null) throw new ArgumentNullException(nameof(typeName)); + file.Seek(0, SeekOrigin.Begin); //reset stream to it's beginning to be able to save it XDocument xmlDocument = await XDocument.LoadAsync(file, LoadOptions.None, cancellationToken); file.Seek(0, SeekOrigin.Begin); //reset stream to it's beginning to be able to save it