Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 11, 2012 08:40 AM by kole
Feb 22, 2012 05:36 PM|LINK
We have a chatting system where we used to store temporary data in xml file. Due to concurrent access of the xml file we faced a problem that says "this process cannot access the file because it is being used by another process". By implementing threading
logic we overcome this problem. But we have a issue of getting blank xml file whenever server is restarted. For this we are checking if the xml file is corrupt and trying to regenerate well formed xml. As the xml file is corrupt, we can't load it to XmlDataDocument
object. Whenever we are using other alternative we are getting previous problem- "this process cannot access the file because it is being used by another process". Please help to overcome this problem.
Feb 22, 2012 05:54 PM|LINK
Every time create a new copy of xml file and use that file , when you finished delete the copy file.
Are you disposing the objects...
us GC.Collect when you are done
Feb 22, 2012 05:55 PM|LINK
What I would do is have a blank copy of the properly formatted XML file in a separate directory. Then when the app start event happens, you can delete the corrupted XML file and then copy the pristine xml file to the new location. Have this code logic inside
your global.asax file and when the app_start fires, this code will run.
Mar 11, 2012 08:40 AM|LINK
Yes, it works. Thanks a lot for your help.