StartupPath optional LocalApplicationData

This commit is contained in:
aucub 2024-12-18 05:04:51 +08:00
parent a6e246948a
commit 6983d21ddc

View file

@ -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 = "")