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);
            }

        }

    }

  • 相关阅读:
    kibana 安装和启动
    Docker安装MariaDB-10.2
    php 生成指定日期范围内的数组
    linux nohup 命令
    git的常用指令(一)
    git的常用指令(二) git add -A 、git add . 和 git add -u
    修改hosts文件 解决coursera可以登录但无法播放视频的问题
    修改mac系统的host文件 (一)
    charles 抓包 (二)
    charles 抓包 (一)
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1345052.html
Copyright © 2011-2022 走看看