json文件存在判断
This commit is contained in:
parent
d3f7d2e07c
commit
4bdb338964
@ -49,7 +49,7 @@ namespace AntdUIDemo
|
|||||||
{
|
{
|
||||||
// 读取 appsettings.json 文件
|
// 读取 appsettings.json 文件
|
||||||
var appSettings = ConfigurationHelper.GetAppSettings();
|
var appSettings = ConfigurationHelper.GetAppSettings();
|
||||||
|
if (appSettings == null) return;
|
||||||
// 加载色彩模式
|
// 加载色彩模式
|
||||||
var value = appSettings["ColorMode"]?.ToString();
|
var value = appSettings["ColorMode"]?.ToString();
|
||||||
if (value == "Auto")
|
if (value == "Auto")
|
||||||
@ -86,6 +86,7 @@ namespace AntdUIDemo
|
|||||||
{
|
{
|
||||||
// 读取 appsettings.json 文件
|
// 读取 appsettings.json 文件
|
||||||
var appSettings = ConfigurationHelper.GetAppSettings();
|
var appSettings = ConfigurationHelper.GetAppSettings();
|
||||||
|
if (appSettings == null) return;
|
||||||
var value = appSettings["ColorMode"]?.ToString();
|
var value = appSettings["ColorMode"]?.ToString();
|
||||||
if (value == "Auto")
|
if (value == "Auto")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,6 +12,10 @@ namespace AntdUIDemo.Utils
|
|||||||
{
|
{
|
||||||
public static JObject GetAppSettings(string configFilePath = "appsettings.json")
|
public static JObject GetAppSettings(string configFilePath = "appsettings.json")
|
||||||
{
|
{
|
||||||
|
if (!File.Exists(configFilePath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// Read the JSON file
|
// Read the JSON file
|
||||||
var json = File.ReadAllText(configFilePath);
|
var json = File.ReadAllText(configFilePath);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user