From 52b8f480f640ce1f55e42ec890ceac8043c65d0c Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 30 Apr 2022 08:32:42 +0800 Subject: [PATCH] Fix issue when saving gui config --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 9c138ca1..2feba3ac 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -210,18 +210,20 @@ namespace v2rayN.Handler { try { - Task.Run(() => - { - //save temp file - var temp = $"{configRes}_temp"; - if (Utils.ToJsonFile(config, Utils.GetPath(temp)) != 0) - { - return; - } - //rename - File.Move(temp, configRes); - }); + //save temp file + var temp = $"{configRes}_temp"; + if (Utils.ToJsonFile(config, Utils.GetPath(temp)) != 0) + { + return; + } + + if (File.Exists(configRes)) + { + File.Delete(configRes); + } + //rename + File.Move(temp, configRes); } catch (Exception ex) {