From 1327b5915ace259cbabbf21dc7b604d4512d319f Mon Sep 17 00:00:00 2001 From: huiyadanli Date: Tue, 12 Dec 2017 11:43:49 +0800 Subject: [PATCH] [#] Create folder when output log --- PasteEx/Program.cs | 1 + PasteEx/Util/Logger.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PasteEx/Program.cs b/PasteEx/Program.cs index 87fff20..dd8b227 100644 --- a/PasteEx/Program.cs +++ b/PasteEx/Program.cs @@ -52,6 +52,7 @@ static void Main(string[] args) command = command.Substring(0, command.Length - 1); } + Client.Start(); Application.Run(new FormMain(command)); } else diff --git a/PasteEx/Util/Logger.cs b/PasteEx/Util/Logger.cs index 4575532..5d9ba33 100644 --- a/PasteEx/Util/Logger.cs +++ b/PasteEx/Util/Logger.cs @@ -10,10 +10,15 @@ namespace PasteEx.Util /// public static class Logger { - private static string path = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "PasteEx", "PasteEx.log"); - static Logger() { + string folder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "PasteEx"); + if (!Directory.Exists(folder)) + { + Directory.CreateDirectory(folder); + } + + string path = Path.Combine(folder, "PasteEx.log"); Trace.Listeners.Add(new TextWriterTraceListener(path)); Trace.AutoFlush = true; }