zoukankan      html  css  js  c++  java
  • Web.config的写入操作

    读的过程很容易,下面给出写入

     1         /// <summary>
     2         /// 修改指定配置节节点信息的值
     3         /// 作    者: KidYang
     4         /// 日    期: 2007-03-27
     5         /// </summary>
     6         /// <param name="appSettingsName">给定配置节节点</param>
     7         /// <param name="newValue">目标值</param>
     8         public static void WriteWebConfig(string appSettingsName, string newValue)
     9         {
    10             string fileName = HttpContext.Current.Server.MapPath(@"~\Web.config");
    11             XmlDocument xmlDoc = new XmlDocument();
    12             xmlDoc.Load(fileName);
    13             XmlNodeList topM = xmlDoc.DocumentElement.ChildNodes;
    14             foreach (XmlElement element in topM)
    15             {
    16                 #region 取得目标节点,并赋新值
    17 
    18                 if (element.Name == "appSettings")
    19                 {
    20                     XmlNodeList node = element.ChildNodes;
    21                     if (node.Count > 0)
    22                     {
    23                         foreach (XmlElement el in node)
    24                         {
    25                             if (el.Attributes["key"].Value == appSettingsName)
    26                             {
    27                                 el.Attributes["value"].Value = newValue;
    28                                 xmlDoc.Save(fileName);
    29                                 return;
    30                             }
    31                         }
    32                     }
    33                 }
    34 
    35                 #endregion
    36             }
    37         }
  • 相关阅读:
    java环境变量配置(转)
    【Android】SlidingMenu属性详解(转)
    android.intent.action.MAIN 与 android.intent.category.LAUNCHER 的验证理解 (转)
    实现Activity刷新(转)
    测试服务API的_苏飞开发助手_使用说明
    在getView方法产生给用户item的视图以及数据
    pl/sql developer 登陆提示ORA-12514(转)
    tnsnames.ora存放路径
    一个较为复杂的布局例子
    Android ImageView图片自适应 (转)
  • 原文地址:https://www.cnblogs.com/EasyLive2006/p/690094.html
Copyright © 2011-2022 走看看