.NET Core中使用读取配置文件
2019-05-23 本文已影响0人
懒懒的程序员一枚
引入Nuget的两个类库
Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.Json
使用
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var configurationRoot = builder.Build();
var motherNameSection = configurationRoot.GetSection("mother").GetSection("name");
