RandomAccess.WriteAsync 方法

定义

重载

名称 说明
WriteAsync(SafeFileHandle, IReadOnlyList<ReadOnlyMemory<Byte>>, Int64, CancellationToken)

将给定缓冲区中的字节序列写入给定偏移量处的给定文件。

WriteAsync(SafeFileHandle, ReadOnlyMemory<Byte>, Int64, CancellationToken)

将给定缓冲区中的字节序列写入给定偏移量处的给定文件。

WriteAsync(SafeFileHandle, IReadOnlyList<ReadOnlyMemory<Byte>>, Int64, CancellationToken)

Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs

将给定缓冲区中的字节序列写入给定偏移量处的给定文件。

public static System.Threading.Tasks.ValueTask WriteAsync(Microsoft.Win32.SafeHandles.SafeFileHandle handle, System.Collections.Generic.IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsync : Microsoft.Win32.SafeHandles.SafeFileHandle * System.Collections.Generic.IReadOnlyList<ReadOnlyMemory<byte>> * int64 * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Shared Function WriteAsync (handle As SafeFileHandle, buffers As IReadOnlyList(Of ReadOnlyMemory(Of Byte)), fileOffset As Long, Optional cancellationToken As CancellationToken = Nothing) As ValueTask

参数

handle
SafeFileHandle

文件句柄。

buffers
IReadOnlyList<ReadOnlyMemory<Byte>>

内存缓冲区的列表。 此方法将这些缓冲区的内容复制到文件。

fileOffset
Int64

要写入的文件位置。

cancellationToken
CancellationToken

用于监视取消请求的令牌。 默认值为 None

返回

表示写入操作的异步完成的任务。

例外

handlebuffersnull.

handle 无效。

文件已关闭。

该文件不支持查找(管道或套接字)。

fileOffset 为负数。

handle 没有打开写作。

出现 I/O 错误。

取消令牌已取消。 此异常存储在返回的任务中。

注解

文件的位置不是高级的。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Write(SafeFileHandle, IReadOnlyList<ReadOnlyMemory<Byte>>, Int64)..

适用于

WriteAsync(SafeFileHandle, ReadOnlyMemory<Byte>, Int64, CancellationToken)

Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs

将给定缓冲区中的字节序列写入给定偏移量处的给定文件。

public static System.Threading.Tasks.ValueTask WriteAsync(Microsoft.Win32.SafeHandles.SafeFileHandle handle, ReadOnlyMemory<byte> buffer, long fileOffset, System.Threading.CancellationToken cancellationToken = default);
static member WriteAsync : Microsoft.Win32.SafeHandles.SafeFileHandle * ReadOnlyMemory<byte> * int64 * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Shared Function WriteAsync (handle As SafeFileHandle, buffer As ReadOnlyMemory(Of Byte), fileOffset As Long, Optional cancellationToken As CancellationToken = Nothing) As ValueTask

参数

handle
SafeFileHandle

文件句柄。

buffer
ReadOnlyMemory<Byte>

内存区域。 此方法将此区域的内容复制到文件。

fileOffset
Int64

要写入的文件位置。

cancellationToken
CancellationToken

用于监视取消请求的令牌。 默认值为 None

返回

表示写入操作的异步完成的任务。

例外

handlenull

handle 无效。

文件已关闭。

该文件不支持查找(管道或套接字)。

fileOffset 为负数。

handle 没有打开写作。

出现 I/O 错误。

取消令牌已取消。 此异常存储在返回的任务中。

注解

文件的位置不是高级的。

适用于