XmlTextWriter file is being used by another process

G

Guoqi Zheng

Dear sir,

I am trying to use XmlTextWriter to create a xml file. It works ok, however
when I reexecute the aspx page again, it always give an error of

"The process cannot access the file "E:\mysite\html\td\product.xml" because
it is being used by another process"

My code is folliowing. Thanks in advanced!!


<mycode>
.....

Dim writer as XmlTextWriter = new XmlTextWriter(filename,Encoding.UTF8)
writer.Formatting = Formatting.Indented

Writer.WriteStartElement("productFeed", nothing)
Writer.WriteAttributeString("version", "0")
' loop the databet and write the elements.

Dim r as DataRow

For Each r in objDataset.Tables("Product").Rows
Writer.WriteStartElement("product")
Writer.WriteAttributeString("id", r("ProductId"))
Writer.WriteAttributeString("delete", "false")
Writer.WriteElementString("name", r("ProductName"))
Writer.WriteStartElement("ProductURL")
Writer.WriteCData(r("LinkUrl"))
Writer.WriteEndElement()

Writer.WriteEndElement()
Writer.Flush()
Next

Writer.WriteEndElement()
writer.close()
</mycode>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top