J
Janiek Buysrogge
Hello,
Can somebody please tell me how I can read values from the following
configuration file. It is generated by VS 2K5 Express when I add
settings using the project properties front-end:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="applicationsettings.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<applicationsettings.Properties.Settings>
<setting name="Test" serializeAs="String">
<value>this is a test value</value>
</setting>
</applicationsettings.Properties.Settings>
</applicationSettings>
</configuration>
The code I have:
Configuration config =
ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
ConfigurationSection appSettings =
config.GetSection("applicationsettings.Properties.Settings");
ConfigurationSectionGroup appSettingsGroup =
config.GetSectionGroup("applicationSettings");
ConfigurationSectionCollection appSettingsSections =
appSettingsGroup.Sections;
foreach (ConfigurationSection section in appSettingsSections)
{
Console.WriteLine(section.SectionInformation.Name);
// stuck here, how do I get children ?
}
First of all, the code I've written seems much to complicated, just
for reading out a simple value.
Second: then what is the correct way to do it, I've read MSDN docs but
they are all based on the AppSettings section. I would like to keep
the xml intact, and read out the value of "Test" in the
"applicationSettings.Properties.Settings" section.
Since MS are saying all other methods of accessing the app.config are
rendered obsolete by the ConfigurationManager class, there must be
some way to do it.
Any help would be greatly appreciated,
Janiek Buysrogge
Can somebody please tell me how I can read values from the following
configuration file. It is generated by VS 2K5 Express when I add
settings using the project properties front-end:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="applicationsettings.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<applicationsettings.Properties.Settings>
<setting name="Test" serializeAs="String">
<value>this is a test value</value>
</setting>
</applicationsettings.Properties.Settings>
</applicationSettings>
</configuration>
The code I have:
Configuration config =
ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
ConfigurationSection appSettings =
config.GetSection("applicationsettings.Properties.Settings");
ConfigurationSectionGroup appSettingsGroup =
config.GetSectionGroup("applicationSettings");
ConfigurationSectionCollection appSettingsSections =
appSettingsGroup.Sections;
foreach (ConfigurationSection section in appSettingsSections)
{
Console.WriteLine(section.SectionInformation.Name);
// stuck here, how do I get children ?
}
First of all, the code I've written seems much to complicated, just
for reading out a simple value.
Second: then what is the correct way to do it, I've read MSDN docs but
they are all based on the AppSettings section. I would like to keep
the xml intact, and read out the value of "Test" in the
"applicationSettings.Properties.Settings" section.
Since MS are saying all other methods of accessing the app.config are
rendered obsolete by the ConfigurationManager class, there must be
some way to do it.
Any help would be greatly appreciated,
Janiek Buysrogge