获取配置文件自定义配置组的配置信息

来源:互联网 发布:婚礼请帖制作软件 编辑:程序博客网 时间:2024/05/21 03:16
 
            _serverDic = new Dictionary<string, List<string>>();
            Configuration config 
= WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

            ConfigurationSectionGroup csg 
= config.GetSectionGroup("remotingConfiguration");

            
foreach(ConfigurationSection csc in csg.Sections)
            
{
                NameValueCollection nvc 
= (NameValueCollection)ConfigurationManager.GetSection(csc.SectionInformation.SectionName);
                List
<string> settings = new List<string>();
                
                
foreach(string key in nvc.AllKeys)
                
{
                    settings.Add(nvc[key]);
                }


                _serverDic.Add(csc.SectionInformation.Name, settings);
            }

原创粉丝点击