修改xml文件方法
修改xml文件方法,下面列子
键LastLoginName,值path
/// <summary>
/// 纪录最后登陆的用户名
/// </summary>
/// <param name="path">登陆的用户名</param>
private static void SetLastLoginName(string path)
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='LastLoginName']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value",path);
doc.Save(Application.ExecutablePath+".config");
}
/// 纪录最后登陆的用户名
/// </summary>
/// <param name="path">登陆的用户名</param>
private static void SetLastLoginName(string path)
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='LastLoginName']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value",path);
doc.Save(Application.ExecutablePath+".config");
}