Update UpgradeApp.cs

pull/5940/head
2dust 2024-10-25 11:56:15 +08:00
parent 78d182fff3
commit 2a5a339c27
1 changed files with 4 additions and 18 deletions

View File

@ -1,6 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO.Compression; using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace AmazTool namespace AmazTool
@ -22,11 +21,11 @@ namespace AmazTool
try try
{ {
Process[] existing = Process.GetProcessesByName(V2rayN()); Process[] existing = Process.GetProcessesByName(V2rayN);
foreach (Process p in existing) foreach (Process p in existing)
{ {
var path = p.MainModule?.FileName ?? ""; var path = p.MainModule?.FileName ?? "";
if (path.StartsWith(GetPath(V2rayN()))) if (path.StartsWith(GetPath(V2rayN)))
{ {
p.Kill(); p.Kill();
p.WaitForExit(100); p.WaitForExit(100);
@ -96,7 +95,7 @@ namespace AmazTool
{ {
StartInfo = new() StartInfo = new()
{ {
FileName = V2rayN(), FileName = V2rayN,
WorkingDirectory = StartupPath() WorkingDirectory = StartupPath()
} }
}; };
@ -123,19 +122,6 @@ namespace AmazTool
return Path.Combine(startupPath, fileName); return Path.Combine(startupPath, fileName);
} }
private static string V2rayN() private static string V2rayN => "v2rayN";
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (File.Exists(GetPath("v2rayN.exe")))
return "v2rayN";
else
return "v2rayN.Desktop";
}
else
{
return "v2rayN.Desktop";
}
}
} }
} }