The first time I called this function, everything went well, but the
second time I called it. An Exception thrown, do you know why?
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"E:\......\bin\Debug\test.xml" because it is being used by another process.
----------------------------------------------
public void updateXMLFile()
{
string AppPath = System.Windows.Forms.Application.StartupPath;
System.Xml.XmlTextWriter XMLWriter = new
System.Xml.XmlTextWriter(AppPath + "/test.xml", System.Text.Encoding.UTF8);
XMLWriter.Formatting = System.Xml.Formatting.Indented;
XMLWriter.Indentation = 1;
/// <summary>
/// <?xml version="1.0" encoding="UTF-8"?>
/// </summary>
XMLWriter.WriteStartDocument();
/// <summary>
/// <root>
/// </summary>
XMLWriter.WriteStartElement("root");
/// <summary>
/// </root>
/// </summary>
XMLWriter.WriteEndElement();
XMLWriter.WriteEndDocument();
XMLWriter.Flush();
XMLWriter.Close();
}
----------------------------------------------