Reputation: 31
I'm having an issue opening files that have recently been closed by the .Net framework. Basically, what happens is the following:
DataSet.ReadXml()
DataSet.WriteXml()
File.Copy
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
Upvotes: 2
Views: 483
Reputation: 2763
Could this possibly be caused by an over eager anti virus program? They may place a lock on it while they inspect the file
Upvotes: 1
Reputation: 2464
Not sure how you are opening the file.
I was having the same problem after closing a text file.
This is what I found that worked:
if (null != sReader) ((IDisposable)sReader).Dispose();
where sreader is
StreamReader sReader
Upvotes: 0