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

定义

开始异步写操作。 请考虑改用 WriteAsync(Byte[], Int32, Int32, CancellationToken)

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

参数

arraybuffer
Byte[]

包含要写入当前流的数据的缓冲区。

offset
Int32

array 中的从零开始的字节偏移量,从此处开始将字节复制到当前流。

numBytescount
Int32

最多写入的字节数。

callbackuserCallback
AsyncCallback

异步写操作完成后调用的方法。

statestateObject
Object

一个用户提供的对象,它将该特定的异步写入请求与其他请求区别开来。

返回

引用异步写入的对象。

例外

array 长度减去 offset 小于 numBytes

arraynull

offsetnumBytes 为负数。

流不支持写入。

流已关闭。

出现 I/O 错误。

适用于

产品 版本
.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