diff --git a/client/Reader/MainForm.cs b/client/Reader/MainForm.cs index 08acd02..77dc99e 100644 --- a/client/Reader/MainForm.cs +++ b/client/Reader/MainForm.cs @@ -13,11 +13,14 @@ namespace Reader public partial class MainForm : Form { private static readonly HttpClient http = new HttpClient(); - private static readonly string ServerUrl = System.IO.File.ReadAllText("appsettings.json") - .Replace("\"", "") - .Split(':')[1] - .Replace("/", "") - .Trim(); + private static readonly string ServerUrl; + + static MainForm() + { + var configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"); + var jsonContent = System.IO.File.ReadAllText(configPath); + ServerUrl = jsonContent.Replace("\"", "").Split(':')[1].Replace("/", "").Trim(); + } public MainForm() { diff --git a/client/Reader/Reader.csproj b/client/Reader/Reader.csproj index ea96263..c48b8d3 100644 --- a/client/Reader/Reader.csproj +++ b/client/Reader/Reader.csproj @@ -6,4 +6,9 @@ enable enable + + + PreserveNewest + + diff --git a/client/Writer/MainForm.cs b/client/Writer/MainForm.cs index d96adb8..09e703c 100644 --- a/client/Writer/MainForm.cs +++ b/client/Writer/MainForm.cs @@ -12,11 +12,14 @@ namespace Writer public partial class MainForm : Form { private static readonly HttpClient http = new HttpClient(); - private static readonly string ServerUrl = System.IO.File.ReadAllText("appsettings.json") - .Replace("\"", "") - .Split(':')[1] - .Replace("/", "") - .Trim(); + private static readonly string ServerUrl; + + static MainForm() + { + var configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"); + var jsonContent = System.IO.File.ReadAllText(configPath); + ServerUrl = jsonContent.Replace("\"", "").Split(':')[1].Replace("/", "").Trim(); + } public MainForm() { diff --git a/client/Writer/Writer.csproj b/client/Writer/Writer.csproj index ea96263..c48b8d3 100644 --- a/client/Writer/Writer.csproj +++ b/client/Writer/Writer.csproj @@ -6,4 +6,9 @@ enable enable + + + PreserveNewest + +