美文网首页
.NET Core中使用读取配置文件

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

作者: 懒懒的程序员一枚 | 来源:发表于2019-05-23 16:44 被阅读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

相关文章

网友评论

      本文标题:.NET Core中使用读取配置文件

      本文链接:https://www.haomeiwen.com/subject/ttebzqtx.html