From 57024a7b2638c45f8734da0a3335ef247c1c5ffc Mon Sep 17 00:00:00 2001 From: ORelio Date: Thu, 26 Feb 2015 12:19:35 +0100 Subject: [PATCH] Fix crash when log file is in same folder Fix #64 by adding an additional check Bug report by JamieSinn (thanks!) --- MinecraftClient/ChatBots/ChatLog.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index c20d6d4d..7d4acc07 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -92,7 +92,9 @@ namespace MinecraftClient.ChatBots if (dateandtime) tosave = getTimestamp() + ' ' + tosave; - Directory.CreateDirectory(Path.GetDirectoryName(logfile)); + string directory = Path.GetDirectoryName(logfile); + if (!String.IsNullOrEmpty(directory) && !Directory.Exists(directory)) + Directory.CreateDirectory(directory); FileStream stream = new FileStream(logfile, FileMode.OpenOrCreate); StreamWriter writer = new StreamWriter(stream); stream.Seek(0, SeekOrigin.End);