zoukankan      html  css  js  c++  java
  • 操作App.config的类(转载)

    http://www.cnblogs.com/yaojiji/archive/2007/12/17/1003191.html

    操作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);       //保存改写文件  
            }
        }
     
     
     
    好文要顶 关注我 
  • 相关阅读:
    存储数据的大小端模式
    双链表插入 删除详解
    php_match/preg_match_all 默认有字符串长度限制
    百度编辑器:获取编辑器的内容
    phalcon: update修改数据却变成了insert插入数据
    MySQL按照汉字的拼音排序,mysql汉字排序
    [转载]Eclipse提示No java virtual machine
    lhgdialog: iframe页面里面的,确定,关闭、取消按钮的操作
    js树目录结构
    mysql:恢复mysql表结构
  • 原文地址:https://www.cnblogs.com/wenjie/p/5711463.html
Copyright © 2011-2022 走看看