Hemant Kothiyal
Hemant Kothiyal

Reputation: 4152

How to read custom config section in app.config in c#

I want to read following custom section from app.config:

<StartupFolders>    
   <Folders name="a">
      <add folderType="Inst" path="c:\foo" />
      <add folderType="Prof" path="C:\foo1" />      
   </Folders>
   <Folders name="b">
      <add folderType="Inst" path="c:\foo" />
      <add folderType="Prof" path="C:\foo1" />      
   </Folders> 
</StartupFolders>

I found this link, but it does not say for multiple <Folders> tag. Please help?

Upvotes: 5

Views: 3818

Answers (1)

JayOnDotNet
JayOnDotNet

Reputation: 398

Hi You can Access custom sections like this

CustomConfigClass section = (CustomConfigClass)ConfigurationManager.GetSection("StartupFolders");

Hope it helps you.

Upvotes: 2

Related Questions