private void PrepareForWriting()
{
if (_fileHandle.IsClosed)
throw Error.GetFileNotOpen();
// Make sure we're good to write. We only need to do this if there's nothing already
// in our write buffer, since if there is something in the buffer, we've already done
// this checking and flushing.
if (_writePos == 0)
{
if (!CanWrite) throw Error.GetWriteNotSupported();
FlushReadBuffer();
Debug.Assert(_bufferLength > 0, "_bufferSize > 0");
}
}