Show / Hide Table of Contents

Class StreamSegment

Delimits a section of a stream.

Inheritance
System.Object
StreamSegment
Namespace: System.IO
Assembly: Nuqleon.IO.StreamSegment.dll
Syntax
public sealed class StreamSegment : Stream

Constructors

StreamSegment(Stream, Int64, Int64)

Creates a new instance of the StreamSegment class representing a segment in the specified stream at the given offset and with the given length.

Declaration
public StreamSegment(Stream stream, long offset, long count)
Parameters
Type Name Description
System.IO.Stream stream

Stream for which to obtain a stream segment.

System.Int64 offset

Offset in the underlying stream where the segment starts.

System.Int64 count

Number of bytes in the segment, starting from the specified offset.

Properties

CanRead

Gets a value indicating whether the current stream supports reading.

Declaration
public override bool CanRead { get; }
Property Value
Type Description
System.Boolean

CanSeek

Gets a value indicating whether the current stream supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
System.Boolean

CanTimeout

Gets a value indicating whether the current stream can time out.

Declaration
public override bool CanTimeout { get; }
Property Value
Type Description
System.Boolean

CanWrite

Gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
System.Boolean

Length

Gets the length in bytes of the stream.

Declaration
public override long Length { get; }
Property Value
Type Description
System.Int64

Position

Gets or sets the position within the current stream.

Declaration
public override long Position { get; set; }
Property Value
Type Description
System.Int64

Methods

Flush()

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Declaration
public override void Flush()

Read(Byte[], Int32, Int32)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

System.Int32 offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

System.Int32 count

The maximum number of bytes to be read from the current stream.

Returns
Type Description
System.Int32

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.

Seek(Int64, SeekOrigin)

Sets the position within the current stream.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
System.Int64 offset

A byte offset relative to the origin parameter.

System.IO.SeekOrigin origin

A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.

Returns
Type Description
System.Int64

The new position within the current stream.

SetLength(Int64)

Sets the length of the current stream.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
System.Int64 value

The desired length of the current stream in bytes.

Write(Byte[], Int32, Int32)

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

An array of bytes. This method copies count bytes from buffer to the current stream.

System.Int32 offset

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

System.Int32 count

The number of bytes to be written to the current stream.

In This Article
Back to top Generated by DocFX