Set Service Configuration Folder

Set service configuration folder to correct location.
This commit is contained in:
Stewart Cossey
2021-02-23 21:28:35 +13:00
parent c11648cc88
commit 4f78cafa21

View File

@@ -34,10 +34,25 @@ namespace DnsService
protected override void OnStart(string[] args)
{
_service = new WebService(null, new Uri("https://go.technitium.com/?id=22"));
_service = new WebService(getConfigFolder(), new Uri("https://go.technitium.com/?id=22"));
_service.Start();
}
/// <summary>
/// If the service file path has the configuration files, use it, otherwise use the localapppath folder.
/// </summary>
/// <returns>The configuration path.</returns>
private string getConfigFolder()
{
string userConfigFolder = String.Concat(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"\Technitium\DNSServer");
if (System.IO.Directory.Exists(Environment.CurrentDirectory))
{
return Environment.CurrentDirectory;
}
return userConfigFolder;
}
protected override void OnStop()
{
_service.Dispose();