Hi,
You performed update in conditional statement.
Try below code
if (!File.Exists(path))
{
XElement xml = new XElement("Formulas",
new XElement("Formula", txtFormula.Text));
xml.Save(path);
}
else
{
XDocument doc = XDocument.Load(path);
var xmlupdate = doc.Descendants("Formulas")
.FirstOrDefault().Element("Formula").Value = txtFormula.Text;
doc.Save(path);
}