C# .Net file in use issue

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-03-08T21:05:37Z Indexed on 2010/03/08 21:06 UTC
Read the original article Hit count: 497

Filed under:
|
|

I'm having an issue opening files that have recently been closed by the .Net framework. Basically, what happens is the following:
-Read in an XML file using DataSet.ReadXml()
-Make some changes to the data
-Write out the XML file using DataSet.WriteXml()
-Copy the XML file to a new location using File.Copy
-FTP the file using a custom control

This sequence can intermittently fail either after the WriteXML or the File.Copy with a file in use exception.
I'm guessing it could be the Windows write cache not flushing right away. Can anyone confirm that this could be causing my issue? Any solutions to suggest?

Thanks,
Dan

© Stack Overflow or respective owner

Related posts about c#

Related posts about file-io