zoukankan      html  css  js  c++  java
  • AppSettings操作类

    /// <summary>
        /// Config文件操作
        /// </summary>
        public class Config
        {
            /// <summary>
            /// 根据Key取Value值
            /// </summary>
            /// <param name="key"></param>
            public static string GetValue(string key)
            {
                return ConfigurationManager.AppSettings[key].ToString().Trim();
            }
            /// <summary>
            /// 根据Key修改Value
            /// </summary>
            /// <param name="key">要修改的Key</param>
            /// <param name="value">要修改为的值</param>
            public static void SetValue(string key, string value)
            {
                System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                xDoc.Load(HttpContext.Current.Server.MapPath("~/XmlConfig/system.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='" + key + "']");
                if (xElem1 != null) xElem1.SetAttribute("value", value);
                else
                {
                    xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", key);
                    xElem2.SetAttribute("value", value);
                    xNode.AppendChild(xElem2);
                }
                xDoc.Save(HttpContext.Current.Server.MapPath("~/XmlConfig/system.config"));
            }
        }
    

      

  • 相关阅读:
    MySQL--mysqldump的权限说明
    JS--switch 语句
    psutil官方文档
    mysql 性能分析套件
    mysql 在启动时配置文件的查找方式
    mysql中的意向锁IS,IX
    mysql innodb_double_write特性
    mysql sql_mode 之 NO_ENGINE_SUBSTITUTION
    编译安装hph
    pip list 和 pip freeze
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/8375870.html
Copyright © 2011-2022 走看看