MemoryMappedFile.CreateFromFile 메서드

정의

기존 파일에서 메모리 매핑된 파일을 만듭니다.

오버로드

CreateFromFile(String)

디스크의 파일에서 메모리 매핑된 파일을 만듭니다.

CreateFromFile(String, FileMode)

디스크의 파일에서 지정된 액세스 모드를 가진 메모리 매핑된 파일을 만듭니다.

CreateFromFile(String, FileMode, String)

디스크의 파일에서 지정된 액세스 모드와 이름을 가진 메모리 매핑된 파일을 만듭니다.

CreateFromFile(String, FileMode, String, Int64)

디스크의 파일에서 지정된 액세스 모드, 이름 및 용량을 가진 메모리 매핑된 파일을 만듭니다.

CreateFromFile(String, FileMode, String, Int64, MemoryMappedFileAccess)

디스크의 파일에서 지정된 액세스 모드, 이름, 용량 및 액세스 형식을 가진 메모리 매핑된 파일을 만듭니다.

CreateFromFile(SafeFileHandle, String, Int64, MemoryMappedFileAccess, HandleInheritability, Boolean)

및 지정된 액세스 모드, 이름, 상속 가능성 및 용량을 사용하여 SafeFileHandle 기존 파일에서 메모리 매핑 파일을 만듭니다.

CreateFromFile(FileStream, String, Int64, MemoryMappedFileAccess, HandleInheritability, Boolean)

지정된 액세스 모드, 이름, 상속 및 용량을 사용하여 기존 파일에서 메모리 매핑된 파일을 만듭니다.

CreateFromFile(FileStream, String, Int64, MemoryMappedFileAccess, MemoryMappedFileSecurity, HandleInheritability, Boolean)

디스크의 파일에서 지정된 이름, 용량, 액세스 형식, 보안 권한, 상속 가능성 및 삭제 요구 사항을 가진 메모리 매핑된 파일을 만듭니다.

CreateFromFile(String)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

디스크의 파일에서 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::String ^ path);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path);
static member CreateFromFile : string -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (path As String) As MemoryMappedFile

매개 변수

path
String

매핑할 파일의 경로입니다.

반환

메모리 매핑된 파일입니다.

예외

path가 길이가 빈 문자열이거나 공백만 포함하거나 GetInvalidFileNameChars() 메서드에 정의된 하나 이상의 잘못된 문자를 포함하는 경우

또는

path는 잘못된 디바이스로 간주합니다.

path이(가) null인 경우

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

path가 운영 체제에 정의된 최대 길이를 초과하는 경우.

호출자에게 파일에 필요한 권한이 없습니다.

예제

다음 예제에서는 메서드를 CreateFromFile 사용하여 메모리 매핑된 파일을 만든 다음 매우 큰 파일의 일부에 대한 메모리 매핑 보기를 만듭니다.

using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;

class Program
{
    static void Main(string[] args)
    {
        long offset = 0x10000000; // 256 megabytes
        long length = 0x20000000; // 512 megabytes

        // Create the memory-mapped file.
        using (var mmf = MemoryMappedFile.CreateFromFile(@"c:\ExtremelyLargeImage.data", FileMode.Open,"ImgA"))
        {
            // 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);
                }
            }
        }
    }
}

public struct MyColor
{
    public short Red;
    public short Green;
    public short Blue;
    public short Alpha;

    // Make the view brighter.
    public void Brighten(short value)
    {
        Red = (short)Math.Min(short.MaxValue, (int)Red + value);
        Green = (short)Math.Min(short.MaxValue, (int)Green + value);
        Blue = (short)Math.Min(short.MaxValue, (int)Blue + value);
        Alpha = (short)Math.Min(short.MaxValue, (int)Alpha + value);
    }
}
Imports System.IO
Imports System.IO.MemoryMappedFiles
Imports System.Runtime.InteropServices

Class Program

    Sub Main()
        Dim offset As Long = &H10000000 ' 256 megabytes
        Dim length As Long = &H20000000 ' 512 megabytes

        ' Create the memory-mapped file.
        Using mmf = MemoryMappedFile.CreateFromFile("c:\ExtremelyLargeImage.data", FileMode.Open, "ImgA")
            ' 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
        End Using
    End Sub
End Class

Public Structure MyColor
    Public Red As Short
    Public Green As Short
    Public Blue As Short
    Public Alpha As Short

    ' Make the view brighter.
    Public Sub Brighten(ByVal value As Short)
        Red = CType(Math.Min(Short.MaxValue, (CType(Red, Integer) + value)), Short)
        Green = CType(Math.Min(Short.MaxValue, (CType(Green, Integer) + value)), Short)
        Blue = CType(Math.Min(Short.MaxValue, (CType(Blue, Integer) + value)), Short)
        Alpha = CType(Math.Min(Short.MaxValue, (CType(Alpha, Integer) + value)), Short)
    End Sub
End Structure

추가 정보

적용 대상

CreateFromFile(String, FileMode)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

디스크의 파일에서 지정된 액세스 모드를 가진 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::String ^ path, System::IO::FileMode mode);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode);
static member CreateFromFile : string * System.IO.FileMode -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (path As String, mode As FileMode) As MemoryMappedFile

매개 변수

path
String

매핑할 파일의 경로입니다.

mode
FileMode

액세스 모드는 Open이어야 합니다.

반환

지정된 액세스 모드를 가진 메모리 매핑된 파일입니다.

예외

path가 길이가 빈 문자열이거나 공백만 포함하거나 GetInvalidFileNameChars() 메서드에 정의된 하나 이상의 잘못된 문자를 포함하는 경우

또는

path는 잘못된 디바이스로 간주합니다.

또는

mode이(가) Append인 경우

path이(가) null인 경우

modeCreate, CreateNew 또는 Truncate입니다.

또는

modeOpenOrCreate이고 디스크에 파일이 존재하지 않는 경우.

또는

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

path가 운영 체제에 정의된 최대 길이를 초과하는 경우.

호출자에게 파일에 필요한 권한이 없습니다.

설명

매개 변수는 mode 디스크의 원본 파일과 관련이 있습니다. 열거형 값만 Open 사용하여 디스크의 원본 파일에서 메모리 매핑 파일을 만들 수 있습니다.

추가 정보

적용 대상

CreateFromFile(String, FileMode, String)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

디스크의 파일에서 지정된 액세스 모드와 이름을 가진 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::String ^ path, System::IO::FileMode mode, System::String ^ mapName);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string? mapName);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string mapName);
static member CreateFromFile : string * System.IO.FileMode * string -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (path As String, mode As FileMode, mapName As String) As MemoryMappedFile

매개 변수

path
String

매핑할 파일의 경로입니다.

mode
FileMode

액세스 모드는 Open이어야 합니다.

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

반환

지정된 이름과 액세스 모드를 가진 메모리 매핑된 파일입니다.

예외

path가 길이가 빈 문자열이거나 공백만 포함하거나 GetInvalidFileNameChars() 메서드에 정의된 하나 이상의 잘못된 문자를 포함하는 경우

또는

path는 잘못된 디바이스로 간주합니다.

또는

mapName이 빈 문자열인 경우

또는

mode이(가) Append인 경우

path이(가) null인 경우

modeCreate, CreateNew 또는 Truncate입니다.

또는

modeOpenOrCreate이고 디스크에 파일이 존재하지 않는 경우.

또는

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

path가 운영 체제에 정의된 최대 길이를 초과하는 경우.

호출자에게 파일에 필요한 권한이 없습니다.

설명

매개 변수는 mode 디스크의 원본 파일과 관련이 있습니다. 열거형 값만 Open 사용하여 디스크의 원본 파일에서 메모리 매핑 파일을 만들 수 있습니다.

적용 대상

CreateFromFile(String, FileMode, String, Int64)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

디스크의 파일에서 지정된 액세스 모드, 이름 및 용량을 가진 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::String ^ path, System::IO::FileMode mode, System::String ^ mapName, long capacity);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string? mapName, long capacity);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string mapName, long capacity);
static member CreateFromFile : string * System.IO.FileMode * string * int64 -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (path As String, mode As FileMode, mapName As String, capacity As Long) As MemoryMappedFile

매개 변수

path
String

매핑할 파일의 경로입니다.

mode
FileMode

액세스 모드는 FileMode를 제외하고는 Append 열거형이 될 수 있습니다.

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

capacity
Int64

메모리 매핑된 파일에 할당할 최대 크기(바이트)입니다. 용량을 디스크에 있는 파일의 크기로 설정하려면 0을 지정합니다.

반환

지정된 특성을 가진 메모리 매핑된 파일입니다.

예외

path가 길이가 빈 문자열이거나 공백만 포함하거나 GetInvalidFileNameChars() 메서드에 정의된 하나 이상의 잘못된 문자를 포함하는 경우

또는

path는 잘못된 디바이스로 간주합니다.

또는

mapName이 빈 문자열인 경우

또는

mode이(가) Append인 경우

path이(가) null인 경우

capacity는 논리 주소 공간의 크기보다 큽니다.

또는

capacity가 0보다 작은 경우

또는

capacity가 파일 크기보다 작습니다(0은 아님).

또는

capacity가 0 이고 디스크의 파일 크기도 0 입니다.

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

path가 운영 체제에 정의된 최대 길이를 초과하는 경우.

호출자에게 파일에 필요한 권한이 없습니다.

설명

매개 변수는 mode 디스크의 원본 파일과 관련이 있습니다.

가 디스크의 파일 크기보다 큰 경우 capacity 메모리 매핑된 파일에 데이터가 기록되지 않더라도 디스크의 파일이 지정된 용량과 일치하도록 증가합니다. 이 문제가 발생하지 않도록 하려면 디스크의 파일 크기로 내부적으로 설정 capacity 되는 기본 용량에 대해 0을 지정합니다.

적용 대상

CreateFromFile(String, FileMode, String, Int64, MemoryMappedFileAccess)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

디스크의 파일에서 지정된 액세스 모드, 이름, 용량 및 액세스 형식을 가진 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::String ^ path, System::IO::FileMode mode, System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string? mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
[System.Security.SecurityCritical]
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
static member CreateFromFile : string * System.IO.FileMode * string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedFile
[<System.Security.SecurityCritical>]
static member CreateFromFile : string * System.IO.FileMode * string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (path As String, mode As FileMode, mapName As String, capacity As Long, access As MemoryMappedFileAccess) As MemoryMappedFile

매개 변수

path
String

매핑할 파일의 경로입니다.

mode
FileMode

액세스 모드는 FileMode를 제외하고는 Append 열거형이 될 수 있습니다.

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

capacity
Int64

메모리 매핑된 파일에 할당할 최대 크기(바이트)입니다. 용량을 디스크에 있는 파일의 크기로 설정하려면 0을 지정합니다.

access
MemoryMappedFileAccess

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

반환

지정된 특성을 가진 메모리 매핑된 파일입니다.

특성

예외

mapName이 빈 문자열인 경우

또는

access이 허용되는 값이 아닌 경우.

또는

path는 빈 파일을 지정합니다.

또는

accessRead로 지정되고 용량이 path에 지정된 파일 크기보다 큽니다.

또는

mode이(가) Append인 경우

path이(가) null인 경우

capacity는 논리 주소 공간의 크기보다 큽니다.

또는

capacity가 0보다 작은 경우

또는

capacity가 파일 크기보다 작습니다(0은 아님).

또는

capacity가 0 이고 디스크의 파일 크기도 0 입니다.

또는

access는 정의된 MemoryMappedFileAccess 값이 아닙니다.

또는

path에 나타난 파일 크기가 capacity보다 큰 경우

또는

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

path가 운영 체제에 정의된 최대 길이를 초과하는 경우.

호출자에게 파일에 필요한 권한이 없습니다.

설명

매개 변수는 mode 디스크의 원본 파일과 관련이 있습니다.

가 디스크의 파일 크기보다 큰 경우 capacity 메모리 매핑된 파일에 데이터가 기록되지 않더라도 디스크의 파일이 지정된 용량과 일치하도록 증가합니다. 이 문제가 발생하지 않도록 하려면 디스크의 파일 크기로 내부적으로 설정 capacity 되는 기본 용량에 대해 0을 지정합니다.

추가 정보

적용 대상

CreateFromFile(SafeFileHandle, String, Int64, MemoryMappedFileAccess, HandleInheritability, Boolean)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

및 지정된 액세스 모드, 이름, 상속 가능성 및 용량을 SafeFileHandle 사용하여 기존 파일에서 메모리 매핑 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(Microsoft::Win32::SafeHandles::SafeFileHandle ^ fileHandle, System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access, System::IO::HandleInheritability inheritability, bool leaveOpen);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle, string? mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.HandleInheritability inheritability, bool leaveOpen);
static member CreateFromFile : Microsoft.Win32.SafeHandles.SafeFileHandle * string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.HandleInheritability * bool -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (fileHandle As SafeFileHandle, mapName As String, capacity As Long, access As MemoryMappedFileAccess, inheritability As HandleInheritability, leaveOpen As Boolean) As MemoryMappedFile

매개 변수

fileHandle
SafeFileHandle

SafeFileHandle 기존 파일에 대한 입니다. 호출자는 가 true 인 경우 leaveOpen 삭제를 담당합니다fileHandle(그렇지 않으면 에서 자동으로 삭제MemoryMappedFile됨).

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

capacity
Int64

메모리 매핑된 파일에 할당할 최대 크기(바이트)입니다. 용량을 파일 크기로 설정하려면 0을 지정합니다.

access
MemoryMappedFileAccess

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

이 매개 변수는 Write로 설정할 수 없습니다.

inheritability
HandleInheritability

메모리 매핑된 파일의 핸들을 자식 프로세스가 상속할 수 있는지 여부를 지정하는 열거형 값 중 하나입니다. 기본값은 None입니다.

leaveOpen
Boolean

가 삭제될 때 MemoryMappedFile 소스 파일 핸들을 닫을지 여부를 나타내는 값입니다.

반환

지정된 특성을 가진 메모리 매핑된 파일입니다.

예외

mapNamenull 또는 빈 문자열인 경우

또는

capacity 및 파일 길이가 0입니다.

또는

access 는 허용되지 않는 로 Write설정됩니다.

또는

access 가 로 Read 설정되고 capacity 가 파일 길이보다 큽니다.

fileHandlenull입니다.

capacity가 0보다 작은 경우

또는

capacity가 파일 크기보다 작습니다.

또는

access가 유효한 MemoryMappedFileAccess 열거형 값이 아닙니다.

또는

inheritability가 유효한 HandleInheritability 열거형 값이 아닙니다.

적용 대상

CreateFromFile(FileStream, String, Int64, MemoryMappedFileAccess, HandleInheritability, Boolean)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs

지정된 액세스 모드, 이름, 상속 및 용량을 사용하여 기존 파일에서 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::IO::FileStream ^ fileStream, System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access, System::IO::HandleInheritability inheritability, bool leaveOpen);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (System.IO.FileStream fileStream, string? mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.HandleInheritability inheritability, bool leaveOpen);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (System.IO.FileStream fileStream, string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.HandleInheritability inheritability, bool leaveOpen);
static member CreateFromFile : System.IO.FileStream * string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.HandleInheritability * bool -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (fileStream As FileStream, mapName As String, capacity As Long, access As MemoryMappedFileAccess, inheritability As HandleInheritability, leaveOpen As Boolean) As MemoryMappedFile

매개 변수

fileStream
FileStream

기존 파일의 파일 스트림입니다.

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

capacity
Int64

메모리 매핑된 파일에 할당할 최대 크기(바이트)입니다. 용량을 의 크기 filestream로 설정하려면 0을 지정합니다.

access
MemoryMappedFileAccess

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

이 매개 변수는 Write로 설정할 수 없습니다.

inheritability
HandleInheritability

메모리 매핑된 파일의 핸들을 자식 프로세스가 상속할 수 있는지 여부를 지정하는 열거형 값 중 하나입니다. 기본값은 None입니다.

leaveOpen
Boolean

MemoryMappedFile이 삭제되면 소스 파일 스트림을 닫을지 여부를 나타내는 값입니다.

반환

지정된 특성을 가진 메모리 매핑된 파일입니다.

예외

mapNamenull 또는 빈 문자열인 경우

또는

capacity 및 파일 길이가 0입니다.

또는

accessWrite 또는 Write 열거형 값으로 설정되며, 허용되지 않습니다.

또는

accessRead로 설정되고 capacityfilestream의 길이 보다 큽니다.

fileStream이(가) null인 경우

capacity가 0보다 작은 경우

또는

capacity가 파일 크기보다 작습니다.

또는

access가 유효한 MemoryMappedFileAccess 열거형 값이 아닙니다.

또는

inheritability가 유효한 HandleInheritability 열거형 값이 아닙니다.

적용 대상

CreateFromFile(FileStream, String, Int64, MemoryMappedFileAccess, MemoryMappedFileSecurity, HandleInheritability, Boolean)

디스크의 파일에서 지정된 이름, 용량, 액세스 형식, 보안 권한, 상속 가능성 및 삭제 요구 사항을 가진 메모리 매핑된 파일을 만듭니다.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateFromFile(System::IO::FileStream ^ fileStream, System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access, System::IO::MemoryMappedFiles::MemoryMappedFileSecurity ^ memoryMappedFileSecurity, System::IO::HandleInheritability inheritability, bool leaveOpen);
[System.Security.SecurityCritical]
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateFromFile (System.IO.FileStream fileStream, string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileSecurity memoryMappedFileSecurity, System.IO.HandleInheritability inheritability, bool leaveOpen);
[<System.Security.SecurityCritical>]
static member CreateFromFile : System.IO.FileStream * string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.MemoryMappedFiles.MemoryMappedFileSecurity * System.IO.HandleInheritability * bool -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateFromFile (fileStream As FileStream, mapName As String, capacity As Long, access As MemoryMappedFileAccess, memoryMappedFileSecurity As MemoryMappedFileSecurity, inheritability As HandleInheritability, leaveOpen As Boolean) As MemoryMappedFile

매개 변수

fileStream
FileStream

매핑할 파일에 대한 fileStream입니다.

mapName
String

메모리 매핑된 파일에 할당할 이름 또는 프로세스 간에 공유하지 않으려는 MemoryMappedFile에 대한 null입니다.

capacity
Int64

메모리 매핑된 파일에 할당할 최대 크기(바이트)입니다. 용량을 디스크에 있는 파일의 크기로 설정하려면 0을 지정합니다.

access
MemoryMappedFileAccess

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

이 매개 변수는 Write로 설정할 수 없습니다.

memoryMappedFileSecurity
MemoryMappedFileSecurity

메모리 매핑된 파일에 대한 파일 액세스 및 작업에 부여할 수 있는 권한입니다.

이 매개 변수는 null일 수 있습니다.

inheritability
HandleInheritability

메모리 매핑된 파일의 핸들을 자식 프로세스가 상속할 수 있는지 여부를 지정하는 열거형 값 중 하나입니다. 기본값은 None입니다.

leaveOpen
Boolean

MemoryMappedFile이 닫힌 후 fileStream을 삭제하지 않으려면 true이고 fileStream을 삭제하려면 false입니다.

반환

지정된 특성을 가진 메모리 매핑된 파일입니다.

특성

예외

mapName이 빈 문자열인 경우

또는

capacity 및 파일 길이가 0입니다.

또는

accessRead 또는 Write 열거형으로 설정되며, 허용되지 않습니다.

fileStream이(가) null인 경우

capacity가 0보다 작은 경우

또는

capacity가 파일 크기보다 작습니다.

또는

access가 유효한 MemoryMappedFileAccess 열거형 값이 아닙니다.

또는

inheritability가 유효한 HandleInheritability 열거형 값이 아닙니다.

fileStream이 닫힌 경우

access의 액세스가 ReadWrite 또는 Read로 설정된 경우 fileStreamWrite로 설정됩니다.

mapName가 이미 있는 경우

설명

가 디스크의 파일 크기보다 큰 경우 capacity 메모리 매핑된 파일에 데이터가 기록되지 않더라도 디스크의 파일이 지정된 용량과 일치하도록 증가합니다. 이 문제가 발생하지 않도록 하려면 디스크의 파일 크기로 내부적으로 설정 capacity 되는 기본 용량에 대해 0을 지정합니다.

추가 정보

적용 대상