Working on a VSTO Outlook addin. I need to store configuration parameters in an XML file. I am struggling with some basic config file loading issue. I would appreciate a fresh view:
customConfiguration.xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="CDSSettings" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<CDSSettings>
<add key="APIusername" value="myUser" />
<add key="APIpassword" value="myPassword" />
</CDSSettings>
<appSettings>
<add key="logLevel" value="0" />
</appSettings>
</configuration>
Code
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = "customConfiguration.xml";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
AppSettingsSection appSettingsSection = (config.GetSection("appSettings") as AppSettingsSection);
// --> All ok
ConfigurationSection CDSSettings = (ConfigurationSection)config.GetSection("CDSSettings");
// --> How to get the APIusername key?
Any chance I can avoid an XML parser or SectionInformation.GetRawXml()?