Complex app.config setting

  • Thread starter Thread starter wuji
  • Start date Start date
W

wuji

Hi !

I understand that dotNet offers app.config to store application
configuration as below:

<configuration>
<appSetting>
<add key="MySettingKey1" value="MySettingValue1" />
<add key="MySettingKey2" value="MySettingValue2" />
</appSetting>
</configuration>

But this type of configuration is too flat. I want to have something
like this:

<configuration>
<appSetting>
<add key="MySettingKey1" value="MySettingValue1" />
<subElement1>A</subElement1>
<subElement2>B</subElement2>
</add>
</appSetting>
</configuration>

How could this read this using ConfigurationSetting class ?

Thanks

Bob
 
Create as key value pairs and parse. Under 2.0 you have other options, but
today it is done like so:

<configuration>
<appSetting>
<add key="MySettingKey1" value="key=X;Sub1=Y;Sub2=Z" />
</appSetting>
</configuration>



--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
As an alternative, what I have done is to create a class that models my
settings structure and then just serialize and deserialize the class to
an xml file.
 
Back
Top