zoukankan      html  css  js  c++  java
  • App.Config 操作类

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml;

    namespace DataUpper
    {
        
    abstract class AppConfig
        
    {
            
    public static string ReadConfig(string strXmlKey)
            
    {
                
    return System.Configuration.ConfigurationManager.AppSettings[strXmlKey].ToString();
            }

            
    public static void SaveConfig(string strXmlKey,string strXmlValue)
            
    {
                XmlDocument doc 
    = new XmlDocument();

                
    string strFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "DataUpper.exe.config";
                doc.Load(strFileName);

                XmlNodeList nodes 
    = doc.GetElementsByTagName("add");

                
    for (int i = 0; i < nodes.Count; i++)
                
    {
                    XmlAttribute xmlAtt 
    = nodes[i].Attributes["key"];

                    
    if (xmlAtt.Value == strXmlKey)
                    
    {
                        xmlAtt 
    = nodes[i].Attributes["value"];
                        xmlAtt.Value 
    = strXmlValue;
                        
    break;
                    }

                }


                doc.Save(strFileName);
            }

        }

    }

  • 相关阅读:
    ESFramework Demo -- 动态组及群聊Demo(附源码)
    反射整理学习
    JavaScript 每周导读
    SQLSERVER 中的 with锁级别
    代码细节重构:请对我的代码指手划脚
    SQLServer查询死锁语句
    模块加载系统 v16
    数据结构之排序算法C#实现
    浅谈操作系统对内存的管理
    如何编写可维护的面向对象JavaScript代码
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1345052.html
Copyright © 2011-2022 走看看