From a03e9a5b0a8ce13f1d72a7a23b261a694d3f0e70 Mon Sep 17 00:00:00 2001 From: celeron533 Date: Thu, 20 Feb 2020 21:03:04 +0800 Subject: [PATCH] Fix LogForm error after deleted log file --- shadowsocks-csharp/View/LogForm.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shadowsocks-csharp/View/LogForm.cs b/shadowsocks-csharp/View/LogForm.cs index ec5751a7..06b0f678 100644 --- a/shadowsocks-csharp/View/LogForm.cs +++ b/shadowsocks-csharp/View/LogForm.cs @@ -175,7 +175,7 @@ namespace Shadowsocks.View private void InitContent() { - if (string.IsNullOrEmpty(filename)) + if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) return; using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) @@ -203,7 +203,7 @@ namespace Shadowsocks.View this.Text = I18N.GetString("Log Viewer") + $" [in: {Utils.FormatBytes(controller.InboundCounter)}, out: {Utils.FormatBytes(controller.OutboundCounter)}]"; - if (string.IsNullOrEmpty(filename)) + if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) return; try {