WebConfigurationManager读写配置文件
.net1.1中如果需要灵活的操作和读写配置文件并不是十分方便,一般都会在项目中封装一个配置文件管理类来进行读写操作。而在.net2.0中使用ConfigurationManager 和WebConfigurationManager 类可以很好的管理配置文件,ConfigurationManager类在System.Configuration 中,WebConfigurationManager在System.Web.Configuration中。根据MSDN的解释,对于 Web 应用程序配置,建议使用System.Web.Configuration.WebConfigurationManager 类,而不要使用 System.Configuration.ConfigurationManager 类。
如何使用WebConfigurationManager操作配置文件:
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
运行代码之后可以看见配置文件中的改变:
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
修改和删除节点或属性也非常方便:
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
配置文件:
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![WebConfigurationManager读写配置文件 WebConfigurationManager读写配置文件](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
IOS