From 7f2ccb2ef834d1a12176e9ca40175adf71e6886a Mon Sep 17 00:00:00 2001 From: czz_y Date: Mon, 2 Sep 2024 17:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=B1=E8=89=B2=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=88=87=E6=8D=A2=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E4=B8=BAJson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainWindow.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MainWindow.cs b/MainWindow.cs index 233b308..13fde25 100644 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -87,7 +87,12 @@ namespace AntdUIDemo private void Button_color_Click(object sender, EventArgs e) { - var value = ConfigurationManager.AppSettings["ColorMode"]; + // 读取 appsettings.json 文件 + var configFilePath = "appsettings.json"; + var json = File.ReadAllText(configFilePath); + var jsonObj = JObject.Parse(json); + var appSettings = jsonObj["AppSettings"]; + var value = appSettings["ColorMode"]?.ToString(); if (value == "Auto") { //反向设置