App.Config 操作类
 using System;
using System; using System.Collections.Generic;
using System.Collections.Generic; using System.Text;
using System.Text; using System.Xml;
using System.Xml;
 namespace DataUpper
namespace DataUpper {
{ abstract class AppConfig
    abstract class AppConfig {
    { public static string ReadConfig(string strXmlKey)
        public static string ReadConfig(string strXmlKey) {
        { return System.Configuration.ConfigurationManager.AppSettings[strXmlKey].ToString();
            return System.Configuration.ConfigurationManager.AppSettings[strXmlKey].ToString(); }
        } public static void SaveConfig(string strXmlKey,string strXmlValue)
        public static void SaveConfig(string strXmlKey,string strXmlValue) {
        { XmlDocument doc = new XmlDocument();
            XmlDocument doc = new XmlDocument();
 string strFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "DataUpper.exe.config";
            string strFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "DataUpper.exe.config"; doc.Load(strFileName);
            doc.Load(strFileName);
 XmlNodeList nodes = doc.GetElementsByTagName("add");
            XmlNodeList nodes = doc.GetElementsByTagName("add");
 for (int i = 0; i < nodes.Count; i++)
            for (int i = 0; i < nodes.Count; i++) {
            { XmlAttribute xmlAtt = nodes[i].Attributes["key"];
                XmlAttribute xmlAtt = nodes[i].Attributes["key"];
 if (xmlAtt.Value == strXmlKey)
                if (xmlAtt.Value == strXmlKey) {
                { xmlAtt = nodes[i].Attributes["value"];
                    xmlAtt = nodes[i].Attributes["value"]; xmlAtt.Value = strXmlValue;
                    xmlAtt.Value = strXmlValue; break;
                    break; }
                } }
            }
 doc.Save(strFileName);
            doc.Save(strFileName); }
        } }
    } }
}
 
                     
                    
                 
                    
                 


 
     
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号