C# 修改APPconfig设置
来源:互联网 发布:知党章党规,系列讲话 编辑:程序博客网 时间:2024/06/05 02:34
#region 修改APPconfig设置 public static void SetConfigValue(string AppKey, string AppValue) { System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.Load(Application.StartupPath + "//LedInfoSystem.dll.config"); System.Xml.XmlNode xNode; System.Xml.XmlElement xElem1; System.Xml.XmlElement xElem2; xNode = xDoc.SelectSingleNode("//appSettings"); xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']"); if (xElem1 != null) xElem1.SetAttribute("value", AppValue); else { xElem2 = xDoc.CreateElement("add"); xElem2.SetAttribute("key", AppKey); xElem2.SetAttribute("value", AppValue); xNode.AppendChild(xElem2); } xDoc.Save(Application.StartupPath + "//LedInfoSystem.dll.config"); } public static string GetConfigValue(string AppKey) { System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.Load(Application.StartupPath + "//LedInfoSystem.dll.config"); System.Xml.XmlNode xNode; System.Xml.XmlElement xElem1; xNode = xDoc.SelectSingleNode("//appSettings"); xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']"); string appValue = xElem1.Value; return appValue; } public static void SetWebServiceAddressValue(string AppValue) { System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config"); System.Xml.XmlNode xNode; System.Xml.XmlElement xElem1; xNode = xDoc.SelectSingleNode("//client"); xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//endpoint[@address]"); if (xElem1 != null) xElem1.SetAttribute("address", AppValue); xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config"); } public static string GetWebServiceAddressValue() { System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config"); System.Xml.XmlNode xNode; System.Xml.XmlElement xElem1; xNode = xDoc.SelectSingleNode("//client"); xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//endpoint[@address]"); string strAddress = xElem1.GetAttribute("address").ToString(); return strAddress; } #endregion
0 0
- C# 修改APPconfig设置
- c# appconfig
- C# APPCONFIG
- 修改Appconfig文件定义
- 关于WinForm中设置Appconfig的问题
- C#不重启程序读取appconfig
- C#通过读取appconfig文件连接数据库
- C# 读取 appconfig文件配置数据库连接的方法
- C#学习日记2017-02-14 配置文件APPconfig问题
- C# 修改IIS相关设置代码
- C#修改本机IP设置
- C#如何设置窗体不能修改大小
- c# winform 下的装载appconfig的section配置节的问题
- js、c#修改ie设置,针对注册表的修改
- AppConfig读写类
- AppConfig读写类
- 初识.Net appconfig
- 配置文件操作类(.AppConfig)
- Hibernate 学习笔记2
- 修复kaldi中的在线语音识别的bug
- Oracle(7)登录认证及管理员密码找回
- 使用Fiddler 模拟请求数据
- 关于OC的编码规范
- C# 修改APPconfig设置
- c 程序设计语言 第二版 练习题 4-13
- 关于CentOS
- 面经-腾讯实习内推
- C/C++函数指针和函数指针数组用法
- 2017蓝桥杯模拟赛 Problem B: 猜算式(11分)
- 2015年第六届蓝桥杯C/C++程序设计本科B组省赛 牌型种数(结果填空)
- 《自控力》要点总结
- tortoiseSVN使用遇到的问题