2012-10-16 41 views
0

我有具有在web.config中ASP.NET服務器應用程式:如何獲取外部appSettings文件名?

<appSettings file="config\another.config"> 

這樣的設置對於每個dev的不同和在SVN分開儲存。有沒有辦法以編程方式獲得文件名(我不想解析web.config原始文本)?

+0

這是你想要的嗎? http://stackoverflow.com/questions/6341906/read-custom-configuration-file-in-c-sharp-framework-4-0 –

+0

沒有。他知道他的文件名。我正試圖找出它。 –

回答

1

這應該做的伎倆:

Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); 
AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings"); 
String externalFilename = appSettingSection.File; 

您將需要參考System.Web.Configuration這一點。

相關問題