From 64126296780066dcee2b2403f873beb9021c80a2 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Tue, 1 Apr 2014 21:41:45 -0400 Subject: [PATCH] Make logging actually succeed --- NBTExplorer/Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NBTExplorer/Program.cs b/NBTExplorer/Program.cs index 35b8b42..84c88c6 100644 --- a/NBTExplorer/Program.cs +++ b/NBTExplorer/Program.cs @@ -86,7 +86,12 @@ namespace NBTExplorer } try { - using (var writer = new StreamWriter("NBTExplorer.error.log", true)) { + string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NBTExplorer"); + if (!Directory.Exists(logDir)) + Directory.CreateDirectory(logDir); + + string logPath = Path.Combine(logDir, "error.log"); + using (var writer = new StreamWriter(logPath, true)) { writer.WriteLine("NBTExplorer Error Report"); writer.WriteLine(DateTime.Now); writer.WriteLine("-------"); @@ -104,7 +109,7 @@ namespace NBTExplorer } errorText.AppendLine(); - errorText.AppendLine("Additional error detail has been written to NBTExplorer.error.log"); + errorText.AppendLine("Additional error detail has been written to:\n" + logPath); } catch { }