class Stream
Provides a generic view of a sequence of bytes. This is an abstract class.
public IAsyncResult BeginRead( byte[] buffer, int offset, int count, AsyncCallback callback, object state )
Begins an asynchronous read operation. (Consider using instead.)
bufferThe buffer to read the data into.offsetThe byte offset in at which to begin writing data read from the stream.countThe maximum number of bytes to read.callbackAn optional asynchronous callback, to be called when the read is complete.stateA user-provided object that distinguishes this particular asynchronous read request from other requests.- Returns An that represents the asynchronous read, which could still be pending.
public IAsyncResult BeginWrite( byte[] buffer, int offset, int count, AsyncCallback callback, object state )
Begins an asynchronous write operation. (Consider using instead.)
bufferThe buffer to write data from.offsetThe byte offset in from which to begin writing.countThe maximum number of bytes to write.callbackAn optional asynchronous callback, to be called when the write is complete.stateA user-provided object that distinguishes this particular asynchronous write request from other requests.- Returns An that represents the asynchronous write, which could still be pending.
public bool CanRead { get; }
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
- Returns if the stream supports reading; otherwise, .
public bool CanSeek { get; }
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
- Returns if the stream supports seeking; otherwise, .
public bool CanTimeout { get; }
Gets a value that determines whether the current stream can time out.
- Returns A value that determines whether the current stream can time out.
public bool CanWrite { get; }
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
- Returns if the stream supports writing; otherwise, .
public void CopyTo( Stream destination )
Reads the bytes from the current stream and writes them to another stream.
destinationThe stream to which the contents of the current stream will be copied.
public void CopyTo( Stream destination, int bufferSize )
Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
destinationThe stream to which the contents of the current stream will be copied.bufferSizeThe size of the buffer. This value must be greater than zero. The default size is 81920.
public Task CopyToAsync( Stream destination )
Asynchronously reads the bytes from the current stream and writes them to another stream.
destinationThe stream to which the contents of the current stream will be copied.- Returns A task that represents the asynchronous copy operation.
public Task CopyToAsync( Stream destination, int bufferSize )
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
destinationThe stream to which the contents of the current stream will be copied.bufferSizeThe size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.- Returns A task that represents the asynchronous copy operation.
public Task CopyToAsync( Stream destination, int bufferSize, CancellationToken cancellationToken )
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
destinationThe stream to which the contents of the current stream will be copied.bufferSizeThe size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous copy operation.
public Task CopyToAsync( Stream destination, CancellationToken cancellationToken )
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.
destinationThe stream to which the contents of the current stream will be copied.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous copy operation.
public int EndRead( IAsyncResult asyncResult )
Waits for the pending asynchronous read to complete. (Consider using instead.)
asyncResultThe reference to the pending asynchronous request to finish.- Returns The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available.
public void EndWrite( IAsyncResult asyncResult )
Ends an asynchronous write operation. (Consider using instead.)
asyncResultA reference to the outstanding asynchronous I/O request.
public Task FlushAsync( CancellationToken cancellationToken )
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous flush operation.
public long Length { get; }
When overridden in a derived class, gets the length in bytes of the stream.
- Returns A long value representing the length of the stream in bytes.
public static Stream Null
A with no backing store.
public long Position { get; set; }
When overridden in a derived class, gets or sets the position within the current stream.
- Returns The current position within the stream.
public int Read( byte[] buffer, int offset, int count )
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
bufferAn array of bytes. When this method returns, the buffer contains the specified byte array with the values between and ( + - 1) replaced by the bytes read from the current source.offsetThe zero-based byte offset in at which to begin storing the data read from the current stream.countThe maximum number of bytes to be read from the current stream.- Returns The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
public Task<int> ReadAsync( byte[] buffer, int offset, int count )
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
bufferThe buffer to write the data into.offsetThe byte offset in at which to begin writing data from the stream.countThe maximum number of bytes to read.- Returns A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
public Task<int> ReadAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )
Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
bufferThe buffer to write the data into.offsetThe byte offset in at which to begin writing data from the stream.countThe maximum number of bytes to read.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
public int ReadTimeout { get; set; }
Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.
- Returns A value, in milliseconds, that determines how long the stream will attempt to read before timing out.
public long Seek( long offset, SeekOrigin origin )
When overridden in a derived class, sets the position within the current stream.
offsetA byte offset relative to the parameter.originA value of type indicating the reference point used to obtain the new position.- Returns The new position within the current stream.
public void SetLength( long value )
When overridden in a derived class, sets the length of the current stream.
valueThe desired length of the current stream in bytes.
public static Stream Synchronized( Stream stream )
Creates a thread-safe (synchronized) wrapper around the specified object.
streamThe object to synchronize.- Returns A thread-safe object.
public void Write( byte[] buffer, int offset, int count )
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
bufferAn array of bytes. This method copies bytes from to the current stream.offsetThe zero-based byte offset in at which to begin copying bytes to the current stream.countThe number of bytes to be written to the current stream.
public Task WriteAsync( byte[] buffer, int offset, int count )
Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
bufferThe buffer to write data from.offsetThe zero-based byte offset in from which to begin copying bytes to the stream.countThe maximum number of bytes to write.- Returns A task that represents the asynchronous write operation.
public Task WriteAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
bufferThe buffer to write data from.offsetThe zero-based byte offset in from which to begin copying bytes to the stream.countThe maximum number of bytes to write.cancellationTokenThe token to monitor for cancellation requests. The default value is .- Returns A task that represents the asynchronous write operation.
public void WriteByte( byte value )
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
valueThe byte to write to the stream.
public int WriteTimeout { get; set; }
Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.
- Returns A value, in milliseconds, that determines how long the stream will attempt to write before timing out.
public object GetLifetimeService( )
😔 No documentation found.
public object InitializeLifetimeService( )
😔 No documentation found.
public void Write( ReadOnlySpan<byte> buffer )
😔 No documentation found.
public Type GetType( )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public bool Equals( object obj )
😔 No documentation found.
public int ReadAtLeast( Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True )
😔 No documentation found.
public void ReadExactly( byte[] buffer, int offset, int count )
😔 No documentation found.
public ValueTask ReadExactlyAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.
public int ReadByte( )
😔 No documentation found.
public int Read( Span<byte> buffer )
😔 No documentation found.
public ValueTask DisposeAsync( )
😔 No documentation found.
public ValueTask WriteAsync( ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.
public ValueTask<int> ReadAtLeastAsync( Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True, CancellationToken cancellationToken = null )
😔 No documentation found.
public ValueTask ReadExactlyAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken = null )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public ValueTask<int> ReadAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )
😔 No documentation found.
public void Dispose( )
😔 No documentation found.
public void Close( )
😔 No documentation found.
public Task FlushAsync( )
😔 No documentation found.
public void ReadExactly( Span<byte> buffer )
😔 No documentation found.
public void Flush( )
😔 No documentation found.