public void EditXml()
{
string a = Application.StartupPath + "//VPN.exe.config";
XmlDocument doc = new XmlDocument();
doc.Load(a);
XmlNodeList topM=doc.DocumentElement.ChildNodes;
foreach (XmlElement element in topM)
{
if (element.Name.ToLower() == "appsettings")
{
XmlNodeList _node = element.ChildNodes;
if (_node.Count > 0)
{
foreach (XmlElement el in _node)
{
if (el.Attributes["key"].InnerXml.ToLower() == "dbconnection")
{
el.Attributes["value"].Value = "server=" + tbip.Text.Trim() + ";database=" + tbdb.Text.Trim() + ";uid=" + tbna.Text.Trim() + ";pwd=" + tbpwd.Text.Trim();
}
}
}
}
}
doc.Save(a);
MessageBox.Show(this,"修改成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Hide();
LoginOn log = new LoginOn();
log.Show();
}