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

System.IO.FileStream.Seek Method

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

public override long Seek (long offset, SeekOrigin origin)

Parameters

offset
A long containing the position relative to origin from which to begin seeking.
origin
A System.IO.SeekOrigin value specifying the beginning, the end, or the current position as a reference point for offset.

Returns

A long containing the new position in the stream.

Exceptions

TypeReason
System.IO.IOExceptionAn I/O error occurred.
NotSupportedExceptionThe stream does not support seeking.
ArgumentExceptionAttempted seeking before the beginning of the stream or to more than one byte past the end of the stream.
ObjectDisposedExceptionThe current stream is closed.

Remarks

Note: Use the FileStream.CanSeek property to determine whether the current instance supports seeking. For additional information, see Stream.CanSeek .

Usage
The position can be set beyond the end of the stream.

Note: This method overrides Stream.Seek(long, SeekOrigin).

Requirements

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