I write code like this
XDocument doc;
if (!System.IO.File.Exists(file))
{
doc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
new System.Xml.Linq.XElement("HEADDERS"));
}
else
{
doc = XDocument.Load(file);
XElement ele = new XElement("Name", TextBox1.Text);
doc.Root.Element("HEADDER").Add(ele);
doc.Save(file);
}
But this shows an error. " Object reference not set to an instance of an object."