.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");
1660640-20190523152211549-903384370.png
上一篇 下一篇

猜你喜欢

热点阅读