what I am trying to do is for my App.config file i have a bunch of settings, and what i want to do split up my config file into different files. For example; my app.config file file has setting pertaining to emails, so i want to take those settings out and store it in an email.config file and then in my app.config file use the configSource attribute to add thos settings from the email.config file and add it to the app settings node. Is this possible?
If so please advice on how to acheive the above result.
Many thanks.
so for example i have another config file called app1.config and has the following xml:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings >
<add key="l" value="test"/>
</appSettings>
</configuration>
and then from my main app.config file have a reference to the app1.config file and then from code be able to do this to get the value of the app setting key:
var x = ConfigurationManager.AppSettings["l"];
EDIT to reflect changed question and additional comments:
For custom settings defined in the
<appSettings>part of the config file there is afileattribute that can contain the path to a file that overrides the appSettings parameters:http://www.codeproject.com/Articles/8818/Using-the-File-attribute-of-the-appSettings-elemen
You can indeed also use the configSource attribute, as specified in the MSDN documentation:
http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx
Or, if you want to store info from the same section in separate files, you can always revert to using the ConfigurationManager.Open…Configuration functions and read the settings programatically:
http://msdn.microsoft.com/en-us/library/ms134262.aspx