Read custom configuration file in C# (Framework 4.0)
Solution 1:
// Map the roaming configuration file. This
// enables the application to access
// the configuration file using the
// System.Configuration.Configuration class
ExeConfigurationFileMap configFileMap =
new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename =
roamingConfig.FilePath;
// Get the mapped configuration file.
Configuration config =
ConfigurationManager.OpenMappedExeConfiguration(
configFileMap, ConfigurationUserLevel.None);
from http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx
Solution 2:
In the past I've used Nini - http://nini.sourceforge.net/manual.php which allows you to read / write custom configuration files (XML / Ini / Registry / .Config) at runtime.
Hope this helps.
Solution 3:
My advice with configuration is create your own component to read it.
It may ease the development if at some point you'll decide that you will be getting the configuration from another source like a database or over a web service.
This kind of abstraction also helps you mock the configuration and increases testability (something that the .NET framework doesn't do well at all).
If you are using XML as the configuration format I suggest using Linq to XML.
It's easier to read and use to parse XML files.