Skip to content

Commit

Permalink
Update v2rayUpgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Sep 6, 2024
1 parent 9c7446f commit c061a24
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions v2rayN/v2rayUpgrade/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static void Main(string[] args)
{
string thisAppOldFile = $"{GetExePath()}.tmp";
File.Delete(thisAppOldFile);
string startKey = "v2rayN/";
string splitKey = "/";

using ZipArchive archive = ZipFile.OpenRead(fileName);
foreach (ZipArchiveEntry entry in archive.Entries)
Expand All @@ -77,11 +77,11 @@ private static void Main(string[] args)
{
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);
Expand All @@ -90,6 +90,8 @@ private static void Main(string[] args)
string entryOutputPath = GetPath(fullName);
Directory.CreateDirectory(Path.GetDirectoryName(entryOutputPath)!);
entry.ExtractToFile(entryOutputPath, true);

Console.WriteLine(entryOutputPath);
}
catch (Exception ex)
{
Expand All @@ -104,11 +106,12 @@ private static void Main(string[] args)
}
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");
}

Expand Down

0 comments on commit c061a24

Please sign in to comment.