File.ReadAllBytesAsync(String, CancellationToken) 方法

定义

以异步形式打开一个二进制文件,将文件的内容读入一个字节数组,然后关闭该文件。Asynchronously opens a binary file, reads the contents of the file into a byte array, and then closes the file.

public static System.Threading.Tasks.Task<byte[]> ReadAllBytesAsync (string path, System.Threading.CancellationToken cancellationToken = default);
static member ReadAllBytesAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<byte[]>
Public Shared Function ReadAllBytesAsync (path As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Byte())

参数

path
String

要打开以进行读取的文件。The file to open for reading.

cancellationToken
CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests. 默认值是 NoneThe default value is None.

返回

Task<Byte[]>

表示异步读取操作的任务,该任务包装包含文件内容的字节数组。A task that represents the asynchronous read operation, which wraps the byte array containing the contents of the file.

适用于