From e03fe9fec993dd27addd5263b172e33f76fd752f Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Mon, 1 Mar 2021 23:14:12 +0800 Subject: [PATCH] throw MessageException when Guard.MainFile not found. --- Netch/Controllers/Guard.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Netch/Controllers/Guard.cs b/Netch/Controllers/Guard.cs index 78633713..691e174e 100644 --- a/Netch/Controllers/Guard.cs +++ b/Netch/Controllers/Guard.cs @@ -17,15 +17,15 @@ namespace Netch.Controllers { private readonly Timer _flushFileStreamTimer = new(300) {AutoReset = true}; + private FileStream? _logFileStream; + + private StreamWriter? _logStreamWriter; + /// /// 日志文件(重定向输出文件) /// private string LogPath => Path.Combine(Global.NetchDir, $"logging\\{Name}.log"); - private FileStream? _logFileStream; - - private StreamWriter? _logStreamWriter; - /// /// 成功启动关键词 /// @@ -107,6 +107,9 @@ namespace Netch.Controllers WindowStyle = ProcessWindowStyle.Hidden } }; + + if (!File.Exists(Instance.StartInfo.FileName)) + throw new MessageException(i18N.Translate($"bin\\{MainFile} file not found!")); } ///