FileStream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) Method

Definition

Begins an asynchronous write operation. Consider using WriteAsync(Byte[], Int32, Int32, CancellationToken) instead.

public override IAsyncResult BeginWrite (byte[] array, int offset, int numBytes, AsyncCallback? callback, object? state);
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback? callback, object? state);
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
public override IAsyncResult BeginWrite (byte[] array, int offset, int numBytes, AsyncCallback callback, object state);
public override IAsyncResult BeginWrite (byte[] array, int offset, int numBytes, AsyncCallback callback, object? state);
public override IAsyncResult BeginWrite (byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject);

Parameters

arraybuffer
Byte[]

The buffer containing data to write to the current stream.

offset
Int32

The zero-based byte offset in array at which to begin copying bytes to the current stream.

numBytescount
Int32

The maximum number of bytes to write.

callbackuserCallback
AsyncCallback

The method to be called when the asynchronous write operation is completed.

statestateObject
Object

A user-provided object that distinguishes this particular asynchronous write request from other requests.

Returns

An object that references the asynchronous write.

Exceptions

array length minus offset is less than numBytes.

array is null.

offset or numBytes is negative.

The stream does not support writing.

The stream is closed.

An I/O error occurred.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1