Table of Contents

Class OffsetStream

Namespace
NanoByte.Common.Streams
Assembly
NanoByte.Common.dll

Decorator that transparently applies an offset to another Stream.

public sealed class OffsetStream : DelegatingStream
Inheritance
OffsetStream
Inherited Members
Extension Methods

Constructors

OffsetStream(Stream)

Decorator that transparently applies an offset to another Stream.

public OffsetStream(Stream underlyingStream)

Parameters

underlyingStream Stream

Underlying stream to delegate to. Will be disposed together with this stream.

Properties

Length

When overridden in a derived class, gets the length in bytes of the stream.

public override long Length { get; }

Property Value

long

A long value representing the length of the stream in bytes.

Exceptions

NotSupportedException

A class derived from Stream does not support seeking.

ObjectDisposedException

Methods were called after the stream was closed.

Position

When overridden in a derived class, gets or sets the position within the current stream.

public override long Position { get; set; }

Property Value

long

The current position within the stream.

Exceptions

IOException

An I/O error occurs.

NotSupportedException

The stream does not support seeking.

ObjectDisposedException

Methods were called after the stream was closed.

Methods

ApplyOffset(int)

Applies an offset to the underlying stream.

public void ApplyOffset(int offset)

Parameters

offset int

The number of bytes to offset by. Must not be negative.

Exceptions

IOException

The underlying stream was shorter than the specified offset.

Seek(long, SeekOrigin)

When overridden in a derived class, sets the position within the current stream.

public override long Seek(long offset, SeekOrigin origin)

Parameters

offset long

A byte offset relative to the origin parameter.

origin SeekOrigin

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

Returns

long

The new position within the current stream.

Exceptions

IOException

An I/O error occurs.

NotSupportedException

The stream does not support seeking, such as if the stream is constructed from a pipe or console output.

ObjectDisposedException

Methods were called after the stream was closed.

SetLength(long)

When overridden in a derived class, sets the length of the current stream.

public override void SetLength(long value)

Parameters

value long

The desired length of the current stream in bytes.

Exceptions

IOException

An I/O error occurs.

NotSupportedException

The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output.

ObjectDisposedException

Methods were called after the stream was closed.