UnmanagedMemoryStream.Initialize UnmanagedMemoryStream.Initialize UnmanagedMemoryStream.Initialize UnmanagedMemoryStream.Initialize Method

定義

以安全緩衝區或使用 Unmanaged 記憶體位置的指標,初始化 UnmanagedMemoryStream 類別的新執行個體。Initializes a new instance of the UnmanagedMemoryStream class in a safe buffer, or by using a pointer to an unmanaged memory location.

多載

Initialize(Byte*, Int64, Int64, FileAccess) Initialize(Byte*, Int64, Int64, FileAccess) Initialize(Byte*, Int64, Int64, FileAccess)

使用 Unmanaged 記憶體位置的指標,初始化 UnmanagedMemoryStream 類別的新執行個體。Initializes a new instance of the UnmanagedMemoryStream class by using a pointer to an unmanaged memory location.

Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess)

在安全緩衝區中使用指定的位移、長度和檔案存取,初始化 UnmanagedMemoryStream 類別的新執行個體。Initializes a new instance of the UnmanagedMemoryStream class in a safe buffer with a specified offset, length, and file access.

Initialize(Byte*, Int64, Int64, FileAccess) Initialize(Byte*, Int64, Int64, FileAccess) Initialize(Byte*, Int64, Int64, FileAccess)

重要

此 API 不符合 CLS 規範。

使用 Unmanaged 記憶體位置的指標,初始化 UnmanagedMemoryStream 類別的新執行個體。Initializes a new instance of the UnmanagedMemoryStream class by using a pointer to an unmanaged memory location.

protected:
 void Initialize(System::Byte* pointer, long length, long capacity, System::IO::FileAccess access);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
protected void Initialize (byte* pointer, long length, long capacity, System.IO.FileAccess access);
member this.Initialize : nativeptr<byte> * int64 * int64 * System.IO.FileAccess -> unit

參數

pointer
Byte*

Unmanaged 記憶體位置的指標。A pointer to an unmanaged memory location.

length
Int64 Int64 Int64 Int64

要使用的記憶體長度。The length of the memory to use.

capacity
Int64 Int64 Int64 Int64

指派給資料流的記憶體總量。The total amount of memory assigned to the stream.

access
FileAccess FileAccess FileAccess FileAccess

其中一個 FileAccess 值。One of the FileAccess values.

例外狀況

使用者沒有所需要的使用權限。The user does not have the required permission.

length 值小於 0。The length value is less than zero.

-或--or- capacity 值小於 0。The capacity value is less than zero.

-或--or- length 值的大小足以造成溢位。The length value is large enough to cause an overflow.

備註

這個方法相當於UnmanagedMemoryStream此函式。This method is equivalent to the UnmanagedMemoryStream constructor. 在設定資料流程變數之前, 它支援需要初始化指標的方法, 因此, 無法呼叫參數化的函式。It supports methods that need to initialize the pointer before setting stream variables and, therefore, cannot call the parameterized constructor. 這類方法應該使用無參數的UnmanagedMemoryStream()函式、初始化指標, Initialize然後叫用方法。Such methods should use the parameterless constructor, UnmanagedMemoryStream(), initialize the pointer, and then invoke the Initialize method.

安全性

UnmanagedCode
用於存取非受控記憶體。for accessing unmanaged memory.

SecurityCriticalAttribute
需要完全信任立即呼叫者。requires full trust for the immediate caller. 部分信任或透明的程式碼無法使用這個成員。This member cannot be used by partially trusted or transparent code.

Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess) Initialize(SafeBuffer, Int64, Int64, FileAccess)

在安全緩衝區中使用指定的位移、長度和檔案存取,初始化 UnmanagedMemoryStream 類別的新執行個體。Initializes a new instance of the UnmanagedMemoryStream class in a safe buffer with a specified offset, length, and file access.

protected:
 void Initialize(System::Runtime::InteropServices::SafeBuffer ^ buffer, long offset, long length, System::IO::FileAccess access);
protected void Initialize (System.Runtime.InteropServices.SafeBuffer buffer, long offset, long length, System.IO.FileAccess access);
member this.Initialize : System.Runtime.InteropServices.SafeBuffer * int64 * int64 * System.IO.FileAccess -> unit
Protected Sub Initialize (buffer As SafeBuffer, offset As Long, length As Long, access As FileAccess)

參數

buffer
SafeBuffer SafeBuffer SafeBuffer SafeBuffer

包含 Unmanaged 記憶體資料流的緩衝區。The buffer to contain the unmanaged memory stream.

offset
Int64 Int64 Int64 Int64

緩衝區中的位元組位置,Unmanaged 記憶體資料流會在此處開始。The byte position in the buffer at which to start the unmanaged memory stream.

length
Int64 Int64 Int64 Int64

Unmanaged 記憶體資料流的長度。The length of the unmanaged memory stream.

access
FileAccess FileAccess FileAccess FileAccess

Unmanaged 記憶體資料流的檔案存取模式。The mode of file access to the unmanaged memory stream.

適用於