c# – ConfigurationManager.AppSettings使用另一个配置文件
发布时间:2020-12-15 18:15:57 所属栏目:百科 来源:网络整理
导读:我班上有大约10种方法.在每个方法中,我使用ConfigurationManager.AppSettings从App.config文件中获取值 喜欢 _applicationPort = int.Parse(ConfigurationManager.AppSettings["ApplicationPort"] 我的问题是我想让这个代码从另一个app.config文件中获取AppS
我班上有大约10种方法.在每个方法中,我使用ConfigurationManager.AppSettings从App.config文件中获取值
喜欢 _applicationPort = int.Parse(ConfigurationManager.AppSettings["ApplicationPort"] 我的问题是我想让这个代码从另一个app.config文件中获取AppSettings,如AnotherPoject.exe.config. 解决方法
您还可以将app.config设置为读取另一个文件.像这样的东西:
<?xml version="1.0"?> <configuration> <appSettings file="mycustomfilepathexternal.config"/> </configuration> 而external.config将有appSettings部分: <appSettings> <add key="myKey" value="myValue" /> </appSettings> 有关其他信息,请参阅this msdn. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |