NET Core中使用读取配置文件

时间:2022-06-12 09:15:57
【文件属性】:
文件名称:NET Core中使用读取配置文件
文件大小:342B
文件格式:TXT
更新时间:2022-06-12 09:15:57
net core 引入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");

网友评论