diff --git a/src/Umbraco.Core/XmlExtensions.cs b/src/Umbraco.Core/XmlExtensions.cs index e2518c791a..8707523615 100644 --- a/src/Umbraco.Core/XmlExtensions.cs +++ b/src/Umbraco.Core/XmlExtensions.cs @@ -16,32 +16,6 @@ namespace Umbraco.Core /// internal static class XmlExtensions { - /// - /// Saves the xml document async - /// - /// - /// - /// - public static async Task SaveAsync(this XmlDocument xdoc, string filename) - { - if (xdoc.DocumentElement == null) - throw new XmlException("Cannot save xml document, there is no root element"); - - using (var fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read, bufferSize: 4096, useAsync: true)) - using (var xmlWriter = XmlWriter.Create(fs, new XmlWriterSettings - { - Async = true, - Encoding = Encoding.UTF8, - Indent = true - })) - { - //NOTE: There are no nice methods to write it async, only flushing it async. We - // could implement this ourselves but it'd be a very manual process. - xdoc.WriteTo(xmlWriter); - await xmlWriter.FlushAsync().ConfigureAwait(false); - } - } - public static bool HasAttribute(this XmlAttributeCollection attributes, string attributeName) { return attributes.Cast().Any(x => x.Name == attributeName); diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs index a7c5a75337..07f73e88f6 100644 --- a/src/Umbraco.Web/umbraco.presentation/content.cs +++ b/src/Umbraco.Web/umbraco.presentation/content.cs @@ -844,7 +844,6 @@ namespace umbraco internal void SaveXmlToFile() { LogHelper.Info("Save Xml to file..."); - try { var xml = _xmlContent; // capture (atomic + volatile), immutable anyway @@ -861,7 +860,7 @@ namespace umbraco Directory.CreateDirectory(directoryName); // save - using (var fs = new FileStream(_xmlFileName, FileMode.Create, FileAccess.Write, FileShare.Read, bufferSize: 4096, useAsync: true)) + using (var fs = new FileStream(_xmlFileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { SaveXmlToStream(xml, fs); } diff --git a/src/Umbraco.Web/umbraco.presentation/template.cs b/src/Umbraco.Web/umbraco.presentation/template.cs index 4290ce2acf..50d3876f40 100644 --- a/src/Umbraco.Web/umbraco.presentation/template.cs +++ b/src/Umbraco.Web/umbraco.presentation/template.cs @@ -88,19 +88,20 @@ namespace umbraco string originalPath = IOHelper.MapPath(VirtualPathUtility.ToAbsolute(MasterPageFile)); string copyPath = IOHelper.MapPath(VirtualPathUtility.ToAbsolute(path)); - FileStream fs = new FileStream(originalPath, FileMode.Open, FileAccess.ReadWrite); - StreamReader f = new StreamReader(fs); - String newfile = f.ReadToEnd(); - f.Close(); - fs.Close(); + string newFile; + using (var fs = new FileStream(originalPath, FileMode.Open, FileAccess.ReadWrite)) + using (var f = new StreamReader(fs)) + { + newFile = f.ReadToEnd(); + } - newfile = newfile.Replace("MasterPageFile=\"~/masterpages/", "MasterPageFile=\""); + newFile = newFile.Replace("MasterPageFile=\"~/masterpages/", "MasterPageFile=\""); - fs = new FileStream(copyPath, FileMode.Create, FileAccess.Write); - - StreamWriter replacement = new StreamWriter(fs); - replacement.Write(newfile); - replacement.Close(); + using (var fs = new FileStream(copyPath, FileMode.Create, FileAccess.Write)) + using (var replacement = new StreamWriter(fs)) + { + replacement.Write(newFile); + } } return path;