MemoryMappedFile.CreateViewAccessor 메서드

정의

메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

오버로드

CreateViewAccessor()

메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

CreateViewAccessor(Int64, Int64)

지정된 오프셋과 크기를 가지고 메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

CreateViewAccessor(Int64, Int64, MemoryMappedFileAccess)

지정된 오프셋, 크기 및 액세스 제한을 가지고 메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

CreateViewAccessor()

메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

public:
 System::IO::MemoryMappedFiles::MemoryMappedViewAccessor ^ CreateViewAccessor();
public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor ();
member this.CreateViewAccessor : unit -> System.IO.MemoryMappedFiles.MemoryMappedViewAccessor
Public Function CreateViewAccessor () As MemoryMappedViewAccessor

반환

MemoryMappedViewAccessor

임의로 액세스 가능한 메모리 블록입니다.

예외

메모리 매핑된 파일에 대한 액세스 권한이 없습니다.

설명

메모리 매핑된 파일에 임의로 액세스하기 위해 이 메서드에서 반환된 보기를 사용할 수 있습니다.

추가 정보

적용 대상

CreateViewAccessor(Int64, Int64)

지정된 오프셋과 크기를 가지고 메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

public:
 System::IO::MemoryMappedFiles::MemoryMappedViewAccessor ^ CreateViewAccessor(long offset, long size);
public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor (long offset, long size);
member this.CreateViewAccessor : int64 * int64 -> System.IO.MemoryMappedFiles.MemoryMappedViewAccessor
Public Function CreateViewAccessor (offset As Long, size As Long) As MemoryMappedViewAccessor

매개 변수

offset
Int64

뷰를 시작할 바이트입니다.

size
Int64

뷰의 크기입니다. offset에서 시작하고 메모리 매핑된 파일의 끝에서 대략적으로 끝나는 뷰를 만들려면 0을 지정합니다.

반환

MemoryMappedViewAccessor

임의로 액세스 가능한 메모리 블록입니다.

예외

offset 또는 size는 음수 값입니다.

또는 size가 논리 주소 공간보다 큽니다.

메모리 매핑된 파일에 대한 액세스 권한이 없습니다.

I/O 오류가 발생했습니다.

예제

다음 예제에서는 메모리 매핑된 파일의 뷰를 만들고 편집합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

메모리 매핑된 파일에 임의로 액세스하기 위해 이 메서드에서 반환된 보기를 사용할 수 있습니다.

메모리 매핑된 파일의 전체 보기를 만들려면 매개 변수에 0을 size 지정합니다. 이렇게 하면 뷰 크기가 디스크의 원본 파일 크기보다 클 수 있습니다. 이는 보기가 시스템 페이지 단위로 제공되고 보기 크기가 다음 시스템 페이지 크기로 반올림되기 때문입니다.

추가 정보

적용 대상

CreateViewAccessor(Int64, Int64, MemoryMappedFileAccess)

지정된 오프셋, 크기 및 액세스 제한을 가지고 메모리 매핑된 파일의 뷰에 매핑되는 MemoryMappedViewAccessor를 만듭니다.

public:
 System::IO::MemoryMappedFiles::MemoryMappedViewAccessor ^ CreateViewAccessor(long offset, long size, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access);
public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor (long offset, long size, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
[System.Security.SecurityCritical]
public System.IO.MemoryMappedFiles.MemoryMappedViewAccessor CreateViewAccessor (long offset, long size, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
member this.CreateViewAccessor : int64 * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedViewAccessor
[<System.Security.SecurityCritical>]
member this.CreateViewAccessor : int64 * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedViewAccessor
Public Function CreateViewAccessor (offset As Long, size As Long, access As MemoryMappedFileAccess) As MemoryMappedViewAccessor

매개 변수

offset
Int64

뷰를 시작할 바이트입니다.

size
Int64

뷰의 크기입니다. offset에서 시작하고 메모리 매핑된 파일의 끝에서 대략적으로 끝나는 뷰를 만들려면 0을 지정합니다.

access
MemoryMappedFileAccess

메모리 매핑된 파일에 허용되는 액세스 형식을 지정하는 열거형 값 중 하나입니다. 기본값은 ReadWrite입니다.

반환

MemoryMappedViewAccessor

임의로 액세스 가능한 메모리 블록입니다.

특성

예외

offset 또는 size는 음수 값입니다.

또는 size가 논리 주소 공간보다 큽니다.

access는 메모리 매핑된 파일에 사용할 수 없습니다.

I/O 오류가 발생했습니다.

설명

메모리 매핑된 파일에 임의로 액세스하기 위해 이 메서드에서 반환된 보기를 사용할 수 있습니다.

메모리 매핑된 파일의 전체 보기를 만들려면 매개 변수에 0을 size 지정합니다. 이렇게 하면 뷰 크기가 디스크의 원본 파일 크기보다 클 수 있습니다. 이는 보기가 시스템 페이지 단위로 제공되고 보기 크기가 다음 시스템 페이지 크기로 반올림되기 때문입니다.

추가 정보

적용 대상