獲取配置文件自定義配置組的配置信息

 
            _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);
            }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章