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

旧时模样 提交于 2019-12-07 04:42:41

问题


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?


回答1:


Hi You can Access custom sections like this

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

Hope it helps you.



来源:https://stackoverflow.com/questions/8643498/how-to-read-custom-config-section-in-app-config-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!