Skip to content

Commit

Permalink
Update UpgradeApp.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Oct 25, 2024
1 parent 78d182f commit 2a5a339
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions v2rayN/AmazTool/UpgradeApp.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text;

namespace AmazTool
Expand All @@ -22,11 +21,11 @@ public static void Upgrade(string fileName)

try
{
Process[] existing = Process.GetProcessesByName(V2rayN());
Process[] existing = Process.GetProcessesByName(V2rayN);
foreach (Process p in existing)
{
var path = p.MainModule?.FileName ?? "";
if (path.StartsWith(GetPath(V2rayN())))
if (path.StartsWith(GetPath(V2rayN)))
{
p.Kill();
p.WaitForExit(100);
Expand Down Expand Up @@ -96,7 +95,7 @@ public static void Upgrade(string fileName)
{
StartInfo = new()
{
FileName = V2rayN(),
FileName = V2rayN,
WorkingDirectory = StartupPath()
}
};
Expand All @@ -123,19 +122,6 @@ private static string GetPath(string fileName)
return Path.Combine(startupPath, fileName);
}

private static string V2rayN()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (File.Exists(GetPath("v2rayN.exe")))
return "v2rayN";
else
return "v2rayN.Desktop";
}
else
{
return "v2rayN.Desktop";
}
}
private static string V2rayN => "v2rayN";
}
}

0 comments on commit 2a5a339

Please sign in to comment.