Update the .env file location

This commit is contained in:
Namhyeon Go 2025-02-20 13:54:59 +09:00
parent c4be361f95
commit 3349255d9a
3 changed files with 23 additions and 3 deletions

View File

@ -14,8 +14,10 @@ namespace WelsonJS.Launcher
{
InitializeComponent();
InitializeListView();
// Set the variable file path in the temporary folder
tempFilePath = Path.Combine(Path.GetTempPath(), "welsonjs_default.env");
// Set the variable file path
tempFilePath = Path.Combine(Program.GetAppDataPath(), "welsonjs_default.env");
LoadUserVariables(); // Load variables
}

View File

@ -42,5 +42,22 @@ namespace WelsonJS.Service
ServiceBase.Run(ServicesToRun);
}
}
public static string GetAppDataPath()
{
string path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"welsonjs"
);
Directory.CreateDirectory(path);
if (!Directory.Exists(path))
{
throw new IOException("Failed to create directory: " + path);
}
return path;
}
}
}

View File

@ -9,10 +9,11 @@ namespace WelsonJS.Service
{
private ServiceMain parent;
private Dictionary<string, string> userVariables;
private readonly string envFilePath = Path.Combine(Path.GetTempPath(), "welsonjs_default.env");
private string envFilePath;
public UserVariables(ServiceBase parent)
{
envFilePath = Path.Combine(Program.GetAppDataPath(), "welsonjs_default.env");
this.parent = (ServiceMain)parent;
}