.NET Core中使用读取配置文件

引入Nuget的两个类库json

Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.Json

使用app

var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var configurationRoot = builder.Build();
var motherNameSection = configurationRoot.GetSection("mother").GetSection("name");

相关文章
相关标签/搜索