Mono Class Library: System.IO.Stream Overview | Members

System.IO.Stream.Seek Method

Changes the position within the current stream by the given offset, which is relative to the stated origin. [Edit]

public abstract long Seek (long offset, SeekOrigin origin)

Parameters

offset
A long that specifies the byte offset relative to origin. [Edit]
origin
A System.IO.SeekOrigin value indicating the reference point used to obtain the new position. [Edit]

Returns

A long that specifies the new position within the current stream. [Edit]

Exceptions

TypeReason
NotSupportedExceptionThe stream does not support seeking, such as if the stream is constructed from a pipe or console output. [Edit]
ObjectDisposedExceptionThe stream is closed. [Edit]
System.IO.IOExceptionAn I/O error has occurred. [Edit]

Remarks

Note: Use the Stream.CanSeek property to determine whether the current instance supports seeking.

Operation
If offset is negative, the new position is required to precede the position specified by origin by the number of bytes specified by offset. If offset is zero, the new position is required to be the position specified by origin. If offset is positive, the new position is required to follow the position specified by origin by the number of bytes specified by offset.

Note to Inheritors

Classes derived from System.IO.Stream that support seeking are required to override this method.

[Edit]

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0