读取
View Code
1 ConfigurationManager.AppSettings["isMail"]
修改
View Code
1 public static void SetValue(string path, string KeyName, string AppValue) 2 { 3 XmlDocument xDoc = new XmlDocument(); 4 xDoc.Load(path); 5 XmlNode xNode; 6 XmlElement xElem1; 7 xNode = xDoc.SelectSingleNode("//configuration");//固定查询 AppSettings下节点 8 xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + KeyName + "']"); 9 if (xElem1 != null) xElem1.SetAttribute("value", AppValue); 10 xDoc.Save(path); 11 }