Stream Class
Namespace: System.IO
Assembly: System.Runtime.dll (in .NET Core 2.0 Runtime Package)
Inheritance: Object > Stream
Represents an abstract base class for all streams in the .NET Framework. A stream is an abstraction of a sequence of bytes, such as a file, an input socket, or a pipe. Streams provide a way to read from and write to these sequences.
Properties
-
CanRead
public abstract bool CanRead { get; }Gets a value indicating whether the current stream supports reading.
-
CanSeek
public abstract bool CanSeek { get; }Gets a value indicating whether the current stream supports seeking.
-
CanWrite
public abstract bool CanWrite { get; }Gets a value indicating whether the current stream supports writing.
-
Length
public abstract long Length { get; }Gets the length in bytes of the stream.
-
Position
public abstract long Position { get; set; }Gets or sets the current position within the stream.
Methods
-
Close()
public virtual void Close()Releases the unmanaged resources used by the Stream and its derived classes and optionally releases the managed resources.
-
CopyTo(Stream destination)
public void CopyTo(Stream destination)Copies the current stream to a destination stream.
-
Flush()
public abstract void Flush()Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
-
Read(byte[] buffer, int offset, int count)
public abstract int Read(byte[] buffer, int offset, int count)Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
-
Seek(long offset, SeekOrigin origin)
public abstract long Seek(long offset, SeekOrigin origin)Sets the position within the current stream.
-
SetLength(long value)
public abstract void SetLength(long value)Sets the length of the current stream.
-
Write(byte[] buffer, int offset, int count)
public abstract void Write(byte[] buffer, int offset, int count)Writes bytes to the current stream from a buffer by using data from the given buffer.