Поделиться через


MemoryStream.Seek Method

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

Sets the position within the current stream to the specified value.

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

Syntax

'Declaration
Public Overrides Function Seek ( _
    offset As Long, _
    loc As SeekOrigin _
) As Long
public override long Seek(
    long offset,
    SeekOrigin loc
)

Parameters

  • offset
    Type: System.Int64
    The new position within the stream. This is relative to the loc parameter, and can be positive or negative.

Return Value

Type: System.Int64
The new position within the stream, calculated by combining the initial reference point and the offset.

Exceptions

Exception Condition
IOException

Seeking is attempted before the beginning of the stream.

ArgumentOutOfRangeException

offset is greater than MaxValue.

ArgumentException

There is an invalid SeekOrigin.

ObjectDisposedException

The current stream instance is closed.

Remarks

This method overrides Seek.

Seeking to any location beyond the length of the stream is supported.

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.