c# - 如何在 C# 中读取 app.config 中的自定义配置部分

标签 c# app-config configsection

我想阅读 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>

我找到了 this link , 但它没有说多个 <Folders>标签。请帮忙?

最佳答案

您好,您可以像这样访问自定义部分

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

希望对你有帮助。

关于c# - 如何在 C# 中读取 app.config 中的自定义配置部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8643498/

相关文章:

c# - 如何使用 app.config 阻止 TextWriterTraceListener 附加?

c# - 如何使用 C# 检索 .config 文件中的自定义配置部分列表?

c# - asp.net mvc 3 Razor 和 html 表

c# - fancybox u 未定义

c# - 如何从 lineX 读取到 lineY C#

c# - app.config 中的 FTP 连接

c# - 避免 null 进入列表

VB.Net 如何将 app.config 文件移动到自定义位置

logging - log4net配置异常

c# - app.config 中的部分类型