public override Task CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken) { // The parameter checks must be in sync with the base version: if (destination == null) { throw new ArgumentNullException("destination"); } if (bufferSize <= 0) { throw new ArgumentOutOfRangeException("bufferSize", Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); } if (!CanRead && !CanWrite) { throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_StreamClosed")); } if (!destination.CanRead && !destination.CanWrite) { throw new ObjectDisposedException("destination", Environment.GetResourceString("ObjectDisposed_StreamClosed")); } if (!CanRead) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnreadableStream")); } if (!destination.CanWrite) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnwritableStream")); } Contract.EndContractBlock(); return(_unmanagedStream.CopyToAsync(destination, bufferSize, cancellationToken)); }
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) { // The parameter checks must be in sync with the base version: if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (bufferSize <= 0) { throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum); } if (!CanRead && !CanWrite) { throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed); } if (!destination.CanRead && !destination.CanWrite) { throw new ObjectDisposedException(nameof(destination), SR.ObjectDisposed_StreamClosed); } if (!CanRead) { throw new NotSupportedException(SR.NotSupported_UnreadableStream); } if (!destination.CanWrite) { throw new NotSupportedException(SR.NotSupported_UnwritableStream); } return(_unmanagedStream.CopyToAsync(destination, bufferSize, cancellationToken)); }