Partager via


FileStream.BeginRead Method

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

Begins an asynchronous read.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overrides Function BeginRead ( _
    array As Byte(), _
    offset As Integer, _
    numBytes As Integer, _
    userCallback As AsyncCallback, _
    stateObject As Object _
) As IAsyncResult
[SecuritySafeCriticalAttribute]
public override IAsyncResult BeginRead(
    byte[] array,
    int offset,
    int numBytes,
    AsyncCallback userCallback,
    Object stateObject
)

Parameters

  • array
    Type: array<System.Byte[]
    The buffer to read data into.
  • offset
    Type: System.Int32
    The byte offset in array at which to begin reading.
  • numBytes
    Type: System.Int32
    The maximum number of bytes to read.
  • userCallback
    Type: System.AsyncCallback
    The method to be called when the asynchronous read operation is completed.
  • stateObject
    Type: System.Object
    A user-provided object that distinguishes this particular asynchronous read request from other requests.

Return Value

Type: System.IAsyncResult
An IAsyncResult that references the asynchronous read.

Exceptions

Exception Condition
ArgumentException

The array length minus offset is less than numBytes.

ArgumentNullException

array is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

offset or numBytes is negative.

IOException

An asynchronous read was attempted past the end of the file.

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.