//Check if the file exists so we do not override an existing file
if (!File.Exists(fileName))
{
xmlTextWriter = new XmlTextWriter(fileName, null);
//Add the root node to the document
if (startNode != null)
{
xmlTextWriter.WriteStartDocument();
xmlTextWriter.WriteStartElement(startNode);
xmlTextWriter.WriteEndElement();
xmlTextWriter.WriteEndDocument();
}
xmlTextWriter.Flush();
xmlTextWriter.Close();
}
|