[corlib] Fixed FileStream Write after Read issue
[mono.git] / mcs / class / corlib / System.IO / FileStream.cs
index 9de058fbb3a3a42800baa9f25b84bb13b948515a..42a3984b11d2261adaef4c71aff20ccb7fa47de2 100644 (file)
@@ -639,6 +639,13 @@ namespace System.IO
                                MonoIOError error;
 
                                FlushBuffer ();
+
+                               if (CanSeek && !isExposed) {
+                                       MonoIO.Seek (safeHandle, buf_start, SeekOrigin.Begin, out error);
+                                       if (error != MonoIOError.ERROR_SUCCESS)
+                                               throw MonoIO.GetException (GetSecureFileName (name), error);
+                               }
+
                                int wcount = count;
 
                                while (wcount > 0){