From 6983d21ddcf24ac6c64b0afd1ed422f9f72b498d Mon Sep 17 00:00:00 2001 From: aucub <78630225+aucub@users.noreply.github.com> Date: Wed, 18 Dec 2024 05:04:51 +0800 Subject: [PATCH] StartupPath optional LocalApplicationData --- v2rayN/ServiceLib/Common/Utils.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 05efe27a..04d37032 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -693,9 +693,16 @@ namespace ServiceLib.Common return Environment.ProcessPath ?? Process.GetCurrentProcess().MainModule?.FileName ?? string.Empty; } - public static string StartupPath() - { + public static string StartupPath() { + try { + string tempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "guiConfigs"); + if (!Directory.Exists(tempPath)) { + Directory.CreateDirectory(tempPath); + } return AppDomain.CurrentDomain.BaseDirectory; + } catch (IOException) { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "v2rayN"); + } } public static string GetTempPath(string filename = "")