UnmanagedMemoryStream.Initialize 方法

定义

在安全缓冲区中或使用指向非托管内存位置的指针初始化 UnmanagedMemoryStream 类的新实例。

重载

Initialize(Byte*, Int64, Int64, FileAccess)

使用指向非托管内存位置的指针初始化 UnmanagedMemoryStream 类的新实例。

Initialize(SafeBuffer, Int64, Int64, FileAccess)

在具有指定的偏移量、长度和文件访问的安全缓冲区中初始化 UnmanagedMemoryStream 类的新实例。

Initialize(Byte*, Int64, Int64, FileAccess)

Source:
UnmanagedMemoryStream.cs
Source:
UnmanagedMemoryStream.cs
Source:
UnmanagedMemoryStream.cs

重要

此 API 不符合 CLS。

使用指向非托管内存位置的指针初始化 UnmanagedMemoryStream 类的新实例。

C#
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
protected void Initialize (byte* pointer, long length, long capacity, System.IO.FileAccess access);
C#
[System.CLSCompliant(false)]
protected void Initialize (byte* pointer, long length, long capacity, System.IO.FileAccess access);
C#
protected void Initialize (byte* pointer, long length, long capacity, System.IO.FileAccess access);

参数

pointer
Byte*

指向非托管内存位置的指针。

length
Int64

要使用的内存的长度。

capacity
Int64

分配给流的内存总量。

access
FileAccess

FileAccess 值之一。

属性

例外

用户没有所必需的权限。

pointer 值为 null

length 值小于零。

- 或 -

capacity 值小于零。

- 或 -

length 值太大,导致溢出。

注解

此方法等效于 UnmanagedMemoryStream 构造函数。 它支持在设置流变量之前需要初始化指针的方法,因此无法调用参数化构造函数。 此类方法应使用无参数构造函数 UnmanagedMemoryStream(),初始化指针,然后调用 Initialize 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 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
UWP 10.0

Initialize(SafeBuffer, Int64, Int64, FileAccess)

Source:
UnmanagedMemoryStream.cs
Source:
UnmanagedMemoryStream.cs
Source:
UnmanagedMemoryStream.cs

在具有指定的偏移量、长度和文件访问的安全缓冲区中初始化 UnmanagedMemoryStream 类的新实例。

C#
protected void Initialize (System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access);

参数

buffer
SafeBuffer

要包含非托管内存流的缓冲区。

offset
Int64

启动非托管内存流的缓冲区字节位置。

length
Int64

非托管内存流的长度。

access
FileAccess

非托管内存流的文件访问模式。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 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
UWP 10.0