From c061a249480e2418e8dfda13650217a2627620ce Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:07:48 +0800 Subject: [PATCH] Update v2rayUpgrade --- v2rayN/v2rayUpgrade/Program.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/v2rayN/v2rayUpgrade/Program.cs b/v2rayN/v2rayUpgrade/Program.cs index 906bbde0..ab351ec5 100644 --- a/v2rayN/v2rayUpgrade/Program.cs +++ b/v2rayN/v2rayUpgrade/Program.cs @@ -66,7 +66,7 @@ namespace v2rayUpgrade { string thisAppOldFile = $"{GetExePath()}.tmp"; File.Delete(thisAppOldFile); - string startKey = "v2rayN/"; + string splitKey = "/"; using ZipArchive archive = ZipFile.OpenRead(fileName); foreach (ZipArchiveEntry entry in archive.Entries) @@ -77,11 +77,11 @@ namespace v2rayUpgrade { continue; } - string fullName = entry.FullName; - if (fullName.StartsWith(startKey)) - { - fullName = fullName[startKey.Length..]; - } + + var lst = entry.FullName.Split(splitKey); + if (lst.Length == 1) continue; + string fullName = string.Join(splitKey, lst[1..lst.Length]); + if (string.Equals(GetExePath(), GetPath(fullName), StringComparison.OrdinalIgnoreCase)) { File.Move(GetExePath(), thisAppOldFile); @@ -90,6 +90,8 @@ namespace v2rayUpgrade string entryOutputPath = GetPath(fullName); Directory.CreateDirectory(Path.GetDirectoryName(entryOutputPath)!); entry.ExtractToFile(entryOutputPath, true); + + Console.WriteLine(entryOutputPath); } catch (Exception ex) { @@ -104,11 +106,12 @@ namespace v2rayUpgrade } if (sb.Length > 0) { - Console.WriteLine("Upgrade Failed,Hold ctrl + c to copy to clipboard.\n" + - "(升级失败,按住ctrl+c可以复制到剪贴板)." + sb.ToString()); + Console.WriteLine("Upgrade Failed.\n" + + "(升级失败)." + sb.ToString()); return; } + Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)"); Process.Start("v2rayN"); }