Possible to add sections to app.config?

esnmb

Member
Joined
Jul 12, 2005
Messages
15
Programming Experience
Beginner
Is it possible to add multiple sections to the app.config file? Like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EXCH1" value="Mailbox Store 1" />
<add key="EXCH2" value="Mailbox Store 2" />
</appSettings>
<Path>
<add key="c" value="c:\blah" />
<add key="d" value="d:\blah" />
</Path>
</configuration>
 
Yes it is. You have specify the custom sections you've added in the appropriate standard section and then those custom sections can be found. This example is from the MSDN help topic for the <section> element, which you should read:
VB.NET:
<configuration>

   <configSections>
      <section name="sampleSection"
               type="System.Configuration.SingleTagSectionHandler" />
   </configSections>

   <sampleSection setting1="Value1" 
                  setting2="value two" 
                  setting3="third value" />

</configuration>
Note that you should also read about the System.Configuration namespace to see what classes you can specify in the 'type' attribute of the 'section' element. They will be the ones whose names end with "Handler".
 
I don't see that this has anything to do with Windows Forms though, so this thread has been moved. Please think about the topic of the post and not just what type of application you're working on.
 
Back
Top