日期:2014-05-20 浏览次数:20901 次
///<summary> ///向.config文件的appKey结写入信息AppValue 保存设置 ///</summary> ///<param name="AppKey">节点名</param> ///<param name="AppValue">值</param> private void SetValue(string AppKey, string AppValue) { //Update XmlDocument xDoc = new XmlDocument(); xDoc.Load(_crmUrl); XmlNode xNode; xNode = xDoc.SelectSingleNode("//appSettings"); XmlElement xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']"); XmlElement xElem2; if (xElem1 != null) {xElem1.SetAttribute("value", AppValue); } else { xElem2 = xDoc.CreateElement("add"); xElem2.SetAttribute("key", AppKey); xElem2.SetAttribute("value", AppValue); xNode.AppendChild(xElem2); } xDoc.Save(_crmUrl); }
<add key="cs" value="Data Source=192.0.1.122;Initial Catalog=DB;Persist Security Info=True;User ID=sa;Password=sa" />
<add key="cs" value="Data Source=192.0.1.122;Initial Catalog=DB;Persist Security Info=True;User ID=sa;Password=saData Source=192.0.1.122;Initial Catalog=DB;Persist Security Info=True;User ID=sa;Password=sa" />