winform app.config添加自定义节点
来源:互联网 发布:mac 安装hadoop 编辑:程序博客网 时间:2024/06/05 21:54
在app.config中
userSetting是自己定义的
还要在文件的头部加上configuration这一段
<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <sectionGroup name="userSettings"> <section name="Book.UI.Properties.Settings" type="System.Configuration.NameValueHandle"/> </sectionGroup> </configSections> <connectionStrings> <add name="ConnectionString" connectionString="data source=.;database=HMS;uid=sa;pwd=Mango895;" providerName="System.Data.Sqlclient"/> </connectionStrings> <appSettings> </appSettings> <userSettings> <Book.UI.Properties.Settings> <setting name="userName" serializeAs="String"> <value></value> </setting> </Book.UI.Properties.Settings> </userSettings></configuration>
在代码中引用
string congfigFile = Application.ExecutablePath + ".config"; XmlDocument document = new XmlDocument(); document.Load(congfigFile); XmlNodeList nodes = document.SelectNodes("/configuration/userSettings/Book.UI.Properties.Settings/setting"); foreach (XmlNode item in nodes) { switch (item.Attributes["name"].Value) { case "userName": item.FirstChild.InnerText = this.txtUserName.Text.Trim(); break; default: break; } document.Save(congfigFile); }
可以保存数据到配置文件中
- winform app.config添加自定义节点
- App.Config设置自定义节点
- Winform添加App.config(原)
- winform 选择打印机功能(功能点:存取app.config节点)
- 在Web.config或App.config中的添加自定义配置
- 在Web.config或App.config中的添加自定义配置
- Web.config或App.config 中添加自定义配置
- 在Web.config或App.config中的添加自定义配置
- winform的app.config
- app.config中节点的添加与修改
- .net App.config 自定义配置 获取多个节点
- config文件自定义节点
- Web.config自定义节点
- VC++2005 WINFORM app.config
- 有关winform 配置文件 app.config
- winform app.config 操作类
- WinForm中的配置文件app.Config
- winform读取配置文件App.config
- ContextMenu简介
- Linux ln python
- 动态规划之矩阵链乘法
- sencha touche 问题-[WARN]The current working directory is not a recoginized Sencha SDK
- mysql取字符串字段最大值 排序
- winform app.config添加自定义节点
- Hexo介绍
- 情色网站的另一面:请尊重你不懂的领域【严重推荐阅读】
- hdu2083-简易版之最短距离
- java的十种设计模式
- VS2005创建一个WinCE的应用程序
- 解读Web应用程序安全性问题的本质
- 浏览器如何工作How browsers work翻译
- 第四章 通知Bean