【问题标题】:How to get external appSettings file name?如何获取外部 appSettings 文件名?
【发布时间】:2012-10-06 09:40:44
【问题描述】:
我在 web.config 中有 ASP.NET 服务器应用程序:
<appSettings file="config\another.config">
所以每个开发者的设置都是不同的,并且分别存储在 svn 中。有没有办法以编程方式获取文件名(我不想为此解析 web.config 原始文本)?
【问题讨论】:
标签:
c#
.net-4.0
web-config
asp.net-4.0
【解决方案1】:
这应该可以解决问题:
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
String externalFilename = appSettingSection.File;
您需要为此参考 System.Web.Configuration。