写 XML 文件的
//public static void SetXmlFileValue(string xmlPath, string AppKey, string AppValue)//写xmlPath是文件路径+文件名,AppKey是 Key Name,AppValue是Value
public static void SetXmlFileValue(string xmlPath, string AppKey, string AppValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(xmlPath);
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings";
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']";
if (xElem1 != null)
{
xElem1.SetAttribute("value", AppValue);
}
else
{
xElem2 = xDoc.CreateElement("add"
C# Winform 里面读取 XML 的方法(转)
最新推荐文章于 2020-03-10 15:20:13 发布