FileStream.Seek Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Sets the current position of this stream to the given value.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overrides Function Seek ( _
    offset As Long, _
    origin As SeekOrigin _
) As Long
[SecuritySafeCriticalAttribute]
public override long Seek(
    long offset,
    SeekOrigin origin
)

Parameters

  • offset
    Type: System.Int64
    The point relative to origin from which to begin seeking.
  • origin
    Type: System.IO.SeekOrigin
    Specifies the beginning, the end, or the current position as a reference point for origin, using a value of type SeekOrigin.

Return Value

Type: System.Int64
The new position in the stream.

Exceptions

Exception Condition
IOException

An I/O error occurs.

NotSupportedException

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

ArgumentException

Attempted seeking before the beginning of the stream.

ObjectDisposedException

Methods were called after the stream was closed.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.