FileStream.BeginWrite Method

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

Begins an asynchronous write.

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


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


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

Return Value

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


Exception Condition

array length minus offset is less than numBytes.


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


offset or numBytes is negative.


The stream does not support writing.


The stream is closed.


An I/O error occurs.

Version Information


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


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