读取配置文件方法

方法1:

System.Collections.Specialized.NameValueCollection nvc = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection(sectionName);
string keyValue = nvc.GetValues(keyName)[0].ToString();

方法2:

System.Web.Configuration.WebConfigurationManager.AppSettings[keyName].ToString();

 

参考:


http://blog.sina.com.cn/s/blog_4c2e288b010008c1.html

http://www.cnblogs.com/gerry-bj/archive/2008/08/06/1261712.html

posted @ 2011-12-15 13:25  行野摄色  阅读(341)  评论(0编辑  收藏  举报