RandomAccess.Read 方法

定义

重载

名称 说明
Read(SafeFileHandle, IReadOnlyList<Memory<Byte>>, Int64)

从给定的偏移量处读取给定文件中的字节序列。

Read(SafeFileHandle, Span<Byte>, Int64)

从给定的偏移量处读取给定文件中的字节序列。

Read(SafeFileHandle, IReadOnlyList<Memory<Byte>>, Int64)

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

从给定的偏移量处读取给定文件中的字节序列。

public:
 static long Read(Microsoft::Win32::SafeHandles::SafeFileHandle ^ handle, System::Collections::Generic::IReadOnlyList<Memory<System::Byte>> ^ buffers, long fileOffset);
public static long Read(Microsoft.Win32.SafeHandles.SafeFileHandle handle, System.Collections.Generic.IReadOnlyList<Memory<byte>> buffers, long fileOffset);
static member Read : Microsoft.Win32.SafeHandles.SafeFileHandle * System.Collections.Generic.IReadOnlyList<Memory<byte>> * int64 -> int64
Public Shared Function Read (handle As SafeFileHandle, buffers As IReadOnlyList(Of Memory(Of Byte)), fileOffset As Long) As Long

参数

handle
SafeFileHandle

文件句柄。

buffers
IReadOnlyList<Memory<Byte>>

内存缓冲区的列表。 此方法返回时,缓冲区的内容将替换为从文件中读取的字节。

fileOffset
Int64

要从中读取的文件位置。

返回

读取到缓冲区中的字节总数。 如果当前没有可用字节数,则这可以小于缓冲区中分配的字节数;如果达到文件的末尾,则为零(0)。

例外

handlebuffersnull.

handle 无效。

文件已关闭。

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

fileOffset 为负数。

handle 未打开阅读。

出现 I/O 错误。

注解

文件的位置不是高级的。

适用于

Read(SafeFileHandle, Span<Byte>, Int64)

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

从给定的偏移量处读取给定文件中的字节序列。

public:
 static int Read(Microsoft::Win32::SafeHandles::SafeFileHandle ^ handle, Span<System::Byte> buffer, long fileOffset);
public static int Read(Microsoft.Win32.SafeHandles.SafeFileHandle handle, Span<byte> buffer, long fileOffset);
static member Read : Microsoft.Win32.SafeHandles.SafeFileHandle * Span<byte> * int64 -> int
Public Shared Function Read (handle As SafeFileHandle, buffer As Span(Of Byte), fileOffset As Long) As Integer

参数

handle
SafeFileHandle

文件句柄。

buffer
Span<Byte>

内存区域。 此方法返回时,此区域的内容将替换为从文件中读取的字节。

fileOffset
Int64

要从中读取的文件位置。

返回

读取到缓冲区中的字节总数。 如果当前没有可用字节数,则缓冲区中分配的字节数可能小于零(0),如果已到达文件的末尾,则为零(0)。

例外

handlenull

handle 无效。

文件已关闭。

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

fileOffset 为负数。

handle 未打开阅读。

出现 I/O 错误。

注解

文件的位置不是高级的。

适用于