fixed a bug

This commit is contained in:
2026-03-29 11:46:01 +08:00
parent fd23679ead
commit 038f65ccc6
4 changed files with 26 additions and 10 deletions

View File

@@ -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()
{

View File

@@ -6,4 +6,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>