#region 保存指定节点值
private bool SaveRegCode(string regCode, string key)
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Application.StartupPath + "/StoreManageV3.Main.exe.config");
XmlNode connNode = xmlDoc.SelectSingleNode("/configuration/appSettings/add[@key='" + key + "']");
connNode.Attributes["value"].Value = regCode;
xmlDoc.Save(Application.StartupPath + "/StoreManageV3.Main.exe.config");
return true;
}
catch
{
return false;
}
}
#endregion
本文介绍了一种方法,用于在.NET应用中通过XML配置文件保存特定节点的值。使用了XmlDocument类来加载和修改配置文件。
1302

被折叠的 条评论
为什么被折叠?



