日期:2014-05-18 浏览次数:21474 次
System.Xml.XmlDocument domSysinfo=new System.Xml.XmlDocument();
            System.Xml.XmlNode root;
            System.Xml.XmlNode node;
            System.Xml.XmlNodeList nodeList;
            domSysinfo.Load(AppDomain.CurrentDomain.BaseDirectory + "\\app.config");                  
            root=domSysinfo.SelectSingleNode("//configuration"); 
            node=root.SelectSingleNode("//appSettings");
            nodeList=node.SelectNodes("add");
            for(int i=0;i<nodeList.Count;i++)
            {
                if(nodeList[i].Attributes["key"].InnerText.Equals("ConnStr"))//讀                {
                    nodeList[i].Attributes["value"].InnerText="寫";
                }
            }
            domSysinfo.Save(AppDomain.CurrentDomain.BaseDirectory + "\\app.config");
------解决方案--------------------
你的WindowsApplication项目下有个Properties文件夹,下面有个Settings.settings文件,双击进去,新建一个值,类型选择连接字符串
读的时候:
  string connString = Properties.Settings.Default.ConnString;
写的时候
  Properties.Settings.Default.ConnString=“”;
  Properties.Settings.Defaul.Save();
------解决方案--------------------
9楼的方法很简单,优先考虑