XmlTextWriter and XmlTextReader causes me an error

KFO's Avatar
KFO
Newbie Member
The process cannot access the file 'D:\file.xml' because it is being used by another process.

This is the error i get because i started with Reading the file.xml and then i write it again in the same class using XmlTextWriter and XmlTextReader.
my objective here is to read xml file to process it and provide the user a flexability to edit this xml file and then i rewrite it. However this error is keep coming up to me. I am writing a console and a windows application
any advice?
Thanks
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
2 things

XmlTextWriter and XmlTextReader helps in appending and not editing for that you need to use XMLDocument.

Also regarding the error it looks you are not closing the XML file after reading.