System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory + "XXXXXXX.exe.config";
xDoc.Load(path);
XmlNodeList nodelist = xDoc.DocumentElement.ChildNodes;
foreach (XmlElement xel in nodelist)
{
if (xel.Name.ToLower() == "appsettings")
{
XmlNodeList node = xel.ChildNodes;
if (node.Count > 0)
{
foreach (XmlElement element in node)
{
if (element.Attributes["key"].Value == "url" && textURL.Text != "")
{
element.Attributes["value"].Value = textURL.Text;
xDoc.Save(path);
}
if (element.Attributes["key"].Value == "way" && textDataBase.Text != "")
{
element.Attributes["value"].Value = textDataBase.Text;
xDoc.Save(path);
}
if (element.Attributes["key"].Value == "time" && textTime.Text != "")
{
element.Attributes["value"].Value = textTime.Text.ToString();
xDoc.Save(path);
}
}
}
}
}
}