zoukankan      html  css  js  c++  java
  • XML操作App.config的类

    public class DoConfig
        {
            public static void Editconfig(string Key,string Value)                      
            {
                XmlDocument xmldoc = new XmlDocument();
                string filePath = Application.ExecutablePath + ".config";
                xmldoc.Load(filePath);

                XmlNodeList topM = xmldoc.DocumentElement.ChildNodes;
                foreach (XmlElement element in topM)
                {
                    if (element.Name.ToLower() == "appsettings")     //找到要改写的字段名 
                    {
                        XmlNodeList _node = element.ChildNodes;
                        if (_node.Count > 0)
                        {
                            foreach (XmlElement el in _node)
                            {
                                //el.Attributes[Key].Value = Value;                                                                 //查找并改写 
                                if (el.Attributes["key"].Value == Key)
                                    el.Attributes["value"].Value = Value;
                            }
                        }
                    }
                }
                xmldoc.Save(filePath);       //保存改写文件 
            }
        }
  • 相关阅读:
    jquery防冲突的写法
    easyUI.checkForm
    获取树形节根节点下面所有层级子节点
    自动发布web应用程序或者网站
    MVC UI Jquery
    Linq模糊查询
    常用正则表达式示例
    Easy UI中,当批量操作后,移除总复选框的选中状态
    常用的JS
    检查是否安装或运行了IIS服务
  • 原文地址:https://www.cnblogs.com/lds85930/p/1124737.html
Copyright © 2011-2022 走看看