The process cannot access the file D:\abc.xml because it is being used by another process.

Hi
I am loading a input xml into XML Document (InputXML), processing the xml document and then saves the result in a temporary xml file. When I copy temporary xml file to input xml, it gives me error. I am using File.Copy().
priyanka_kothariAsked:
Who is Participating?
 
priyanka_kothariConnect With a Mentor Author Commented:
Hi

Thanks for the response. I added Thread.Sleep() before copying the files and its working now.
0
 
trebbeCommented:
can you post some code?
0
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
That sounds like you haven't closed the file D:\abc.xml after loading it for processing, so the system won't allow you to replace it.
0
 
priyanka_kothariAuthor Commented:
Instead of loading xmlDocument from file, I first read file into XMLTextReader and then I am loading into XML Document
0
 
priyanka_kothariAuthor Commented:
My problem was solved after i added Thread.Sleep and loaded file from XMLTextReader
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.