MemoryMappedViewAccessor 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示記憶體對應檔的隨機存取檢視。
public ref class MemoryMappedViewAccessor sealed : System::IO::UnmanagedMemoryAccessor
public sealed class MemoryMappedViewAccessor : System.IO.UnmanagedMemoryAccessor
type MemoryMappedViewAccessor = class
inherit UnmanagedMemoryAccessor
Public NotInheritable Class MemoryMappedViewAccessor
Inherits UnmanagedMemoryAccessor
- 繼承
範例
下列範例會 MemoryMappedViewAccessor 從大型記憶體對應檔案取得 以進行編輯。
此程式代碼範例是提供給 類別之較大範例的 MemoryMappedFile 一部分。
// Create a random access view, from the 256th megabyte (the offset)
// to the 768th megabyte (the offset plus length).
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
int colorSize = Marshal.SizeOf(typeof(MyColor));
MyColor color;
// Make changes to the view.
for (long i = 0; i < length; i += colorSize)
{
accessor.Read(i, out color);
color.Brighten(10);
accessor.Write(i, ref color);
}
}
' Create a random access view, from the 256th megabyte (the offset)
' to the 768th megabyte (the offset plus length).
Using accessor = mmf.CreateViewAccessor(offset, length)
Dim colorSize As Integer = Marshal.SizeOf(GetType(MyColor))
Dim color As MyColor
Dim i As Long = 0
' Make changes to the view.
Do While (i < length)
accessor.Read(i, color)
color.Brighten(10)
accessor.Write(i, color)
i += colorSize
Loop
End Using
備註
CreateViewAccessor使用物件的 方法來MemoryMappedFile取得此檢視。
屬性
CanRead |
判斷存取子是否可讀取。 (繼承來源 UnmanagedMemoryAccessor) |
CanWrite |
判斷存取子是否可寫入。 (繼承來源 UnmanagedMemoryAccessor) |
Capacity |
取得存取子的容量。 (繼承來源 UnmanagedMemoryAccessor) |
IsOpen |
判斷存取子目前是否由處理程序開啟。 (繼承來源 UnmanagedMemoryAccessor) |
PointerOffset |
取得這個檢視起始位置與記憶體對應檔案開頭的位移位元組數目。 |
SafeMemoryMappedViewHandle |
取得記憶體對應檔檢視的控制代碼。 |
方法
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應