I am using the following code to write the contents of one xml file to another, the code is just being indented so it is easier to read. Is there any way to modify this so that it can write to the same file? I know it can't write directly because there is a lock, but I tried to duplicate the code and reverse the file names but it still tells me there is a lock. Any help would be greatly appreciated.
David
David
Code:
void IndentXML() {
string filePath = @"c:\file\nc.xml";
XmlDocument doc = new XmlDocument();
doc.Load(@"c:\file\nc2.xml");
XmlTextWriter writer = new XmlTextWriter(filePath2,Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
doc.WriteTo(writer);
writer.Flush();
writer.Close();
}