views:

101

answers:

1

Hi,

I need to parse a config file that is situated in another project. I know that ConfigurationManager reads the app.config file by default (right?) how to make it read that particular config file?

Thank you

+7  A: 
// Create a filemap refering the config file.
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configFilePath;

// Retrieve the config file.
Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
Marcus