diff --git a/src/Umbraco.Core/Logging/Viewer/LogViewerSourceBase.cs b/src/Umbraco.Core/Logging/Viewer/LogViewerSourceBase.cs index 59994a64a6..5ac6353dfb 100644 --- a/src/Umbraco.Core/Logging/Viewer/LogViewerSourceBase.cs +++ b/src/Umbraco.Core/Logging/Viewer/LogViewerSourceBase.cs @@ -32,7 +32,7 @@ namespace Umbraco.Core.Logging.Viewer //Our default implementation //If file does not exist - lets create it with an empty array - IOHelper.EnsureFileExists(_searchesConfigPath, "[]"); + EnsureFileExists(_searchesConfigPath, "[]"); var rawJson = System.IO.File.ReadAllText(_searchesConfigPath); return JsonConvert.DeserializeObject>(rawJson); @@ -50,7 +50,7 @@ namespace Umbraco.Core.Logging.Viewer var rawJson = JsonConvert.SerializeObject(searches, Formatting.Indented); //If file does not exist - lets create it with an empty array - IOHelper.EnsureFileExists(_searchesConfigPath, "[]"); + EnsureFileExists(_searchesConfigPath, "[]"); //Write it back down to file System.IO.File.WriteAllText(_searchesConfigPath, rawJson); @@ -163,6 +163,15 @@ namespace Umbraco.Core.Logging.Viewer }; } - + private void EnsureFileExists(string path, string contents) + { + var absolutePath = IOHelper.MapPath(path); + if (System.IO.File.Exists(absolutePath)) return; + + using (var writer = System.IO.File.CreateText(absolutePath)) + { + writer.Write(contents); + } + } } }