How do you use sections in c# 4.0 app.config?

<configSections>
  <section name="FBI" type="System.Configuration.NameValueSectionHandler" />
  <section name="FSCS" type="System.Configuration.NameValueSectionHandler" />
</configSections>

<FSCS>
  <add key="processingDirectory" value="C:\testfiles\ProccesFolder"/>
</FSCS>
<FBI>
  <add key="processingDirectory" value="C:\testfiles\ProccesFolder"/>
</FBI>

And then:

var section = ConfigurationManager.GetSection("FSCS") as NameValueCollection;
var value = section["processingDirectory"];

Leave a Comment