MemoryMappedFile.CreateOrOpen MemoryMappedFile.CreateOrOpen MemoryMappedFile.CreateOrOpen MemoryMappedFile.CreateOrOpen Method

定義

建立或開啟系統記憶體中的記憶體對應檔。Creates or opens a memory-mapped file in system memory.

多載

CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability)

建立新的空白記憶體對應檔,或開啟現有的記憶體對應檔 (如果有名稱相同的檔案存在)。Creates a new empty memory mapped file or opens an existing memory mapped file if one exists with the same name. 如果開啟現有的檔案,則會忽略容量、選項和記憶體引數。If opening an existing file, the capacity, options, and memory arguments will be ignored.

CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量、存取類型、記憶體配置、安全性權限以及可繼承性。Creates or opens a memory-mapped file that has the specified name, capacity, access type, memory allocation, security permissions, and inheritability in system memory.

CreateOrOpen(String, Int64) CreateOrOpen(String, Int64) CreateOrOpen(String, Int64) CreateOrOpen(String, Int64)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱和容量。Creates or opens a memory-mapped file that has the specified name and capacity in system memory.

CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量和存取類型。Creates or opens a memory-mapped file that has the specified name, capacity and access type in system memory.

CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability)

建立新的空白記憶體對應檔,或開啟現有的記憶體對應檔 (如果有名稱相同的檔案存在)。Creates a new empty memory mapped file or opens an existing memory mapped file if one exists with the same name. 如果開啟現有的檔案,則會忽略容量、選項和記憶體引數。If opening an existing file, the capacity, options, and memory arguments will be ignored.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateOrOpen(System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access, System::IO::MemoryMappedFiles::MemoryMappedFileOptions options, System::IO::HandleInheritability inheritability);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options, System.IO.HandleInheritability inheritability);
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.MemoryMappedFiles.MemoryMappedFileOptions * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateOrOpen (mapName As String, capacity As Long, access As MemoryMappedFileAccess, options As MemoryMappedFileOptions, inheritability As HandleInheritability) As MemoryMappedFile

參數

mapName
String String String String

記憶體對應檔的名稱。The name of the memory-mapped file.

capacity
Int64 Int64 Int64 Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。The maximum size, in bytes, to allocate to the memory-mapped file.

access
MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。One of the enumeration values that specifies the type of access allowed to the memory-mapped file. 預設為 ReadWriteThe default is ReadWrite.

options
MemoryMappedFileOptions MemoryMappedFileOptions MemoryMappedFileOptions MemoryMappedFileOptions

值的位元組合,指出要套用至檔案的記憶體配置選項。A bitwise combination of values that indicate the memory allocation options to apply to the file.

inheritability
HandleInheritability HandleInheritability HandleInheritability HandleInheritability

決定記憶體對應檔的控制代碼是否可以由子處理序繼承的值。A value that specifies whether a handle to the memory-mapped file can be inherited by a child process. 預設為 NoneThe default is None.

傳回

記憶體對應檔,具有指定的特性。A memory-mapped file that has the specified characteristics.

例外狀況

mapName 為空字串。mapName is an empty string.

-或--or- access 設為唯寫,且具有 Write 列舉值。access is set to write-only with the Write enumeration value.

capacity 大於邏輯位址空間的大小。capacity is greater than the size of the logical address space.

-或--or- capacity 小於或等於零。capacity is less than or equal to zero.

-或--or- access 不是有效的 MemoryMappedFileAccess 列舉值。access is not a valid MemoryMappedFileAccess enumeration value.

-或--or- inheritability 不是有效的 HandleInheritability 列舉值。inheritability is not a valid HandleInheritability enumeration value.

作業系統拒絕對檔案進行指定之存取,例如,存取設定為 WriteReadWrite,但是檔案或目錄是唯讀的。The operating system denied the specified access to the file; for example, access is set to Write or ReadWrite, but the file or directory is read-only.

CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability) CreateOrOpen(String, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity, HandleInheritability)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量、存取類型、記憶體配置、安全性權限以及可繼承性。Creates or opens a memory-mapped file that has the specified name, capacity, access type, memory allocation, security permissions, and inheritability in system memory.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateOrOpen(System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access, System::IO::MemoryMappedFiles::MemoryMappedFileOptions options, System::IO::MemoryMappedFiles::MemoryMappedFileSecurity ^ memoryMappedFileSecurity, System::IO::HandleInheritability inheritability);
[System.Security.SecurityCritical]
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options, System.IO.MemoryMappedFiles.MemoryMappedFileSecurity memoryMappedFileSecurity, System.IO.HandleInheritability inheritability);
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.MemoryMappedFiles.MemoryMappedFileOptions * System.IO.MemoryMappedFiles.MemoryMappedFileSecurity * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile

參數

mapName
String String String String

記憶體對應檔的名稱。The name of the memory-mapped file.

capacity
Int64 Int64 Int64 Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。The maximum size, in bytes, to allocate to the memory-mapped file.

access
MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。One of the enumeration values that specifies the type of access allowed to the memory-mapped file. 預設為 ReadWriteThe default is ReadWrite.

options
MemoryMappedFileOptions MemoryMappedFileOptions MemoryMappedFileOptions MemoryMappedFileOptions

列舉值的位元組合,指定記憶體對應檔的記憶體配置選項。A bitwise combination of enumeration values that specifies memory allocation options for the memory-mapped file.

memoryMappedFileSecurity
MemoryMappedFileSecurity MemoryMappedFileSecurity MemoryMappedFileSecurity MemoryMappedFileSecurity

允許對記憶體對應檔進行檔案存取及作業的可授與權限。The permissions that can be granted for file access and operations on memory-mapped files.

這個參數可以是 nullThis parameter can be null.

inheritability
HandleInheritability HandleInheritability HandleInheritability HandleInheritability

其中一個列舉值,決定記憶體對應檔的控制代碼是否可以由子處理序繼承。One of the enumeration values that specifies whether a handle to the memory-mapped file can be inherited by a child process. 預設為 NoneThe default is None.

傳回

記憶體對應檔,具有指定的特性。A memory-mapped file that has the specified characteristics.

例外狀況

mapName 為空字串。mapName is an empty string.

-或--or- access 設為唯寫,且具有 Write 列舉值。access is set to write-only with the Write enumeration value.

capacity 大於邏輯位址空間的大小。capacity is greater than the size of the logical address space.

-或--or- capacity 小於或等於零。capacity is less than or equal to zero.

-或--or- access 不是有效的 MemoryMappedFileAccess 列舉值。access is not a valid MemoryMappedFileAccess enumeration value.

-或--or- inheritability 不是有效的 HandleInheritability 列舉值。inheritability is not a valid HandleInheritability enumeration value.

作業系統拒絕對檔案進行指定之 access,例如,access 設定為 WriteReadWrite,但是檔案或目錄是唯讀的。The operating system denied the specified access to the file; for example, access is set to Write or ReadWrite, but the file or directory is read-only.

備註

使用此方法來建立或開啟不會保存的記憶體對應檔案 (也就是與磁片上的檔案沒有關聯), 您可以使用此檔案在進程之間共用資料。Use this method to create or open a memory-mapped file that is not persisted (that is, not associated with a file on disk), which you can use to share data between processes.

安全性

SecurityPermission
用於存取未受管理的程式碼。for access to unmanaged code. 關聯的列舉型別:UnmanagedCodeAssociated enumeration: UnmanagedCode.

另請參閱

CreateOrOpen(String, Int64) CreateOrOpen(String, Int64) CreateOrOpen(String, Int64) CreateOrOpen(String, Int64)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱和容量。Creates or opens a memory-mapped file that has the specified name and capacity in system memory.

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

參數

mapName
String String String String

記憶體對應檔的名稱。The name of the memory-mapped file.

capacity
Int64 Int64 Int64 Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。The maximum size, in bytes, to allocate to the memory-mapped file.

傳回

記憶體對應檔,具有指定的名稱與大小。A memory-mapped file that has the specified name and size.

例外狀況

mapName 為空字串。mapName is an empty string.

capacity 大於邏輯位址空間的大小。capacity is greater than the size of the logical address space.

-或--or- capacity 小於或等於零。capacity is less than or equal to zero.

備註

使用此方法來建立或開啟不會保存的記憶體對應檔案 (也就是與磁片上的檔案沒有關聯), 您可以使用此檔案在進程之間共用資料。Use this method to create or open a memory-mapped file that is not persisted (that is, not associated with a file on disk), which you can use to share data between processes.

另請參閱

CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess) CreateOrOpen(String, Int64, MemoryMappedFileAccess)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量和存取類型。Creates or opens a memory-mapped file that has the specified name, capacity and access type in system memory.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateOrOpen(System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (string mapName, long capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access);
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateOrOpen (mapName As String, capacity As Long, access As MemoryMappedFileAccess) As MemoryMappedFile

參數

mapName
String String String String

記憶體對應檔的名稱。The name of the memory-mapped file.

capacity
Int64 Int64 Int64 Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。The maximum size, in bytes, to allocate to the memory-mapped file.

access
MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。One of the enumeration values that specifies the type of access allowed to the memory-mapped file. 預設為 ReadWriteThe default is ReadWrite.

傳回

記憶體對應檔,具有指定的特性。A memory-mapped file that has the specified characteristics.

例外狀況

mapName 為空字串。mapName is an empty string.

-或--or- access 設為唯寫,且具有 Write 列舉值。access is set to write-only with the Write enumeration value.

capacity 大於邏輯位址空間的大小。capacity is greater than the size of the logical address space.

-或--or- capacity 小於或等於零。capacity is less than or equal to zero.

-或--or- access 不是有效的 MemoryMappedFileAccess 列舉值。access is not a valid MemoryMappedFileAccess enumeration value.

作業系統拒絕對檔案進行指定之存取,例如,存取設定為 WriteReadWrite,但是檔案或目錄是唯讀的。The operating system denied the specified access to the file; for example, access is set to Write or ReadWrite, but the file or directory is read-only.

備註

使用此方法來建立或開啟不會保存的記憶體對應檔案 (也就是與磁片上的檔案沒有關聯), 您可以使用此檔案在進程之間共用資料。Use this method to create or open a memory-mapped file that is not persisted (that is, not associated with a file on disk), which you can use to share data between processes.

另請參閱

適用於