.Net Core实践3 配置文件

环境

.netcore2.1 / vs2017 / win10 / centos7

在.netcore项目中读取配置文件,先添加应用程序配置文件App.config.这个是类库项目的配置文件名.

System.Configuration.ConfigurationManager.AppSettings[key] 这个仍然有效,但前提是要添加这个的引用

在nuget中找到这个包下载,这个需要 .net standard2.0

仍然使用添加引用的方式,到nuget包中找到这个dll,注意是.netstandard2.0这个版本

就可以使用了,习惯和framework一样.

测试

string path = System.Configuration.ConfigurationManager.AppSettings["path"];

Console.WriteLine(path);

猜你喜欢

转载自www.cnblogs.com/mirrortom/p/9707210.html