title: How do you use sections in c# 4.0 app.config?
body: <p>I want to use my app config to store the settings for 2 companys, and i'd prefer if it was possible to use a section to seperate the data for one from the other rather then giving them diffrent key names.</p>
  
  <p>I have been checking online but i seem to get a bit overwhelmed when people use sections or find outdated easy ways to use them. could anyone pass me a beginner guide on them?</p>
  
  <p>Below is an example of what my app.config would look like:</p>
  
  <pre><code>  &lt;configSections&gt;
      &lt;section name="FBI" type="" /&gt;
      &lt;section name="FSCS" type="" /&gt;
    &lt;/configSections&gt;
  
    &lt;FSCS&gt;
      &lt;add key="processingDirectory" value="C:\testfiles\ProccesFolder"/&gt;
    &lt;/FSCS&gt;
    &lt;FBI&gt;
      &lt;add key="processingDirectory" value="C:\testfiles\ProccesFolder"/&gt;
    &lt;/FBI&gt;
  </code></pre>
  
  <p>Update:</p>
  
  <p>Advanced solution based on the anwer. in case anyone wanted to know.</p>
  
  <p>App.config:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;configSections&gt;
          &lt;sectionGroup name="FileCheckerConfigGroup"&gt;
            &lt;section name="FBI" type="System.Configuration.NameValueSectionHandler" /&gt;
            &lt;section name="FSCS" type="System.Configuration.NameValueSectionHandler" /&gt;
          &lt;/sectionGroup&gt;
      &lt;/configSections&gt;
      &lt;FileCheckerConfigGroup&gt;
          &lt;FSCS&gt;
              &lt;add key="processingDirectory" value="C:\testfiles\ProccesFolder"/&gt;
          &lt;/FSCS&gt;
          &lt;FBI&gt;
              &lt;add key="processingDirectory" value="C:\testfiles\ProccesFolder"/&gt;
          &lt;/FBI&gt;
      &lt;/FileCheckerConfigGroup&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>// Get the application configuration file. 
  System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  
  // Get the collection of the section groups. 
  ConfigurationSectionGroupCollection sectionGroups = config.SectionGroups;
  
  foreach (ConfigurationSectionGroup sectionGroup in sectionGroups)
  {
      if (sectionGroup.Name == "FileCheckerConfigGroup")
      {
          foreach (ConfigurationSection configurationSection in sectionGroup.Sections)
          {
            var section = ConfigurationManager.GetSection(configurationSection.SectionInformation.SectionName) as NameValueCollection;
            inputDirectory = section["inputDirectory"]; //"C:\\testfiles";
          }
      }
  }
  </code></pre>