public override IAsyncResult BeginWrite(byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, Object stateObject) { if (!CanWrite) { throw new NotSupportedException(); } long oldLen = _originalStream.Length; long newLen = _originalStream.CanSeek ? _originalStream.Position + (long)numBytes : _originalStream.Length + (long)numBytes; EnsureQuota(Math.Max(oldLen, newLen)); return _originalStream.BeginWrite(buffer, offset, numBytes, userCallback, stateObject); }