Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 545
Hemant Kothiyal Avatar asked Nov 04 '22 08:11

Hemant Kothiyal


1 Answers

Hi You can Access custom sections like this

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

Hope it helps you.

like image 158
JayOnDotNet Avatar answered Nov 14 '22 13:11

JayOnDotNet