From 3c45ef624af78a9d3037b2aacfeb13307a5f93b5 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Wed, 9 Oct 2024 20:13:25 +0800
Subject: [PATCH] Rename v2rayUpgrade 2 AmazTool
---
.../v2rayUpgrade.csproj => AmazTool/AmazTool.csproj} | 0
v2rayN/{v2rayUpgrade => AmazTool}/Program.cs | 4 ++--
.../{v2rayUpgrade/Upgrade.cs => AmazTool/UpgradeApp.cs} | 8 ++++----
v2rayN/ServiceLib/Common/Utils.cs | 2 +-
v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs | 2 +-
v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs | 2 +-
v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs | 4 ++--
v2rayN/v2rayN.sln | 2 +-
8 files changed, 12 insertions(+), 12 deletions(-)
rename v2rayN/{v2rayUpgrade/v2rayUpgrade.csproj => AmazTool/AmazTool.csproj} (100%)
rename v2rayN/{v2rayUpgrade => AmazTool}/Program.cs (88%)
rename v2rayN/{v2rayUpgrade/Upgrade.cs => AmazTool/UpgradeApp.cs} (95%)
diff --git a/v2rayN/v2rayUpgrade/v2rayUpgrade.csproj b/v2rayN/AmazTool/AmazTool.csproj
similarity index 100%
rename from v2rayN/v2rayUpgrade/v2rayUpgrade.csproj
rename to v2rayN/AmazTool/AmazTool.csproj
diff --git a/v2rayN/v2rayUpgrade/Program.cs b/v2rayN/AmazTool/Program.cs
similarity index 88%
rename from v2rayN/v2rayUpgrade/Program.cs
rename to v2rayN/AmazTool/Program.cs
index 8b9dfe4c..3f61464b 100644
--- a/v2rayN/v2rayUpgrade/Program.cs
+++ b/v2rayN/AmazTool/Program.cs
@@ -1,4 +1,4 @@
-namespace v2rayUpgrade
+namespace AmazTool
{
internal static class Program
{
@@ -16,7 +16,7 @@
}
var fileName = Uri.UnescapeDataString(string.Join(" ", args));
- Upgrade.UpgradeApp(fileName);
+ UpgradeApp.Upgrade(fileName);
}
}
}
\ No newline at end of file
diff --git a/v2rayN/v2rayUpgrade/Upgrade.cs b/v2rayN/AmazTool/UpgradeApp.cs
similarity index 95%
rename from v2rayN/v2rayUpgrade/Upgrade.cs
rename to v2rayN/AmazTool/UpgradeApp.cs
index ef627f10..c5189a33 100644
--- a/v2rayN/v2rayUpgrade/Upgrade.cs
+++ b/v2rayN/AmazTool/UpgradeApp.cs
@@ -3,11 +3,11 @@ using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text;
-namespace v2rayUpgrade
+namespace AmazTool
{
- internal class Upgrade
+ internal class UpgradeApp
{
- public static void UpgradeApp(string fileName)
+ public static void Upgrade(string fileName)
{
Console.WriteLine(fileName);
Console.WriteLine("In progress, please wait...(正在进行中,请等待)");
@@ -105,7 +105,7 @@ namespace v2rayUpgrade
private static string GetExePath()
{
- return Environment.ProcessPath ?? string.Empty;
+ return Environment.ProcessPath ?? Process.GetCurrentProcess().MainModule?.FileName ?? string.Empty;
}
private static string StartupPath()
diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs
index 3414a0e0..d3dc3f69 100644
--- a/v2rayN/ServiceLib/Common/Utils.cs
+++ b/v2rayN/ServiceLib/Common/Utils.cs
@@ -750,7 +750,7 @@ namespace ServiceLib.Common
///
public static string GetExePath()
{
- return Environment.ProcessPath ?? string.Empty;
+ return Environment.ProcessPath ?? Process.GetCurrentProcess().MainModule?.FileName ?? string.Empty;
}
public static string StartupPath()
diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs
index defeb603..09569c40 100644
--- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs
@@ -137,7 +137,7 @@ namespace ServiceLib.ViewModels
var result = await CreateZipFileFromDirectory(fileBackup);
if (result)
{
- Locator.Current.GetService()?.V2rayUpgrade(fileName);
+ Locator.Current.GetService()?.UpgradeApp(fileName);
}
else
{
diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
index 4fc51b1e..f7800ad8 100644
--- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
@@ -235,7 +235,7 @@ namespace ServiceLib.ViewModels
{
return;
}
- Locator.Current.GetService()?.V2rayUpgrade(fileName);
+ Locator.Current.GetService()?.UpgradeApp(fileName);
}
catch (Exception ex)
{
diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
index 63d47341..91e830ed 100644
--- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
@@ -437,13 +437,13 @@ namespace ServiceLib.ViewModels
}
}
- public async Task V2rayUpgrade(string fileName)
+ public async Task UpgradeApp(string fileName)
{
Process process = new()
{
StartInfo = new ProcessStartInfo
{
- FileName = "v2rayUpgrade",
+ FileName = "AmazTool",
Arguments = fileName.AppendQuotes(),
WorkingDirectory = Utils.StartupPath()
}
diff --git a/v2rayN/v2rayN.sln b/v2rayN/v2rayN.sln
index 47689a40..f898d47e 100644
--- a/v2rayN/v2rayN.sln
+++ b/v2rayN/v2rayN.sln
@@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceLib", "ServiceLib\Se
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "v2rayN.Desktop", "v2rayN.Desktop\v2rayN.Desktop.csproj", "{5D16541A-F971-4C17-9315-BB8955E3F984}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "v2rayUpgrade", "v2rayUpgrade\v2rayUpgrade.csproj", "{47D68B1C-601C-4C69-873B-FFF0DC13EC97}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AmazTool", "AmazTool\AmazTool.csproj", "{47D68B1C-601C-4C69-873B-FFF0DC13EC97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution