How do you use sections in c# 4.0 app.config?

后端 未结 2 1180
遥遥无期
遥遥无期 2020-12-07 10:58

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

2条回答
  •  天涯浪人
    2020-12-07 11:59

    App.config

    
      
        

    Example Usage

    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    ConfigurationSectionGroup fileCheckersGroup = config.SectionGroups["FileCheckers"];
    foreach (ConfigurationSection section in fileCheckersGroup.Sections)
    {
        NameValueCollection sectionSettings = ConfigurationManager.GetSection(section.SectionInformation.SectionName) as NameValueCollection;
        var value = sectionSettings["processingDirectory"]
    }
    

提交回复
热议问题