I am trying to create a new file and write to it, but I keep getting the
error 'cannot access the file because it is being used by another
process'. Can anybody help me out?
long lngNextNumber = Find_Next_File_Number();
string strNewFile =
"C:\\inetpub\\wwwroot\\webapplication90\\xml_files \\test" +
lngNextNumber + ".xml";
File.Create(strNewFile);
//create the XMLTextWriter
XmlTextWriter tw = new XmlTextWriter(strNewFile, null);
//set the formatting to indented
tw.Formatting = Formatting.Indented;
tw.WriteStartDocument();
//start creating elements and attributes
tw.WriteStartElement("book");
tw.WriteElementString("title", "Case of the missing cookie");
tw.WriteEndElement();
tw.WriteEndDocument();
//clean up
tw.Flush();
tw.Close();
Cheers,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!