When i closing my application, FileStream sometimes throws IOException in the debug mode:
System.IO.IOException
HResult=0x80131620
Message=The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss.
Source=mscorlib
StackTrace:
at System.IO.FileStream.VerifyOSHandlePosition()
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.FileStream.Finalize()
I didn't check it in the release mode, because this error occurs very rarely. I use the FileStream like this:
using (var stream = new FileStream()) {
// some code
}
No FileStream is open when i close the application.
My application using .NET Framework 4.5 and WPF
User contributions licensed under CC BY-SA 3.0