MemoryMappedFile.CreateOrOpen 方法

定義

建立或開啟系統記憶體中的記憶體對應檔。

多載

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

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量、存取類型、記憶體配置、安全性權限以及可繼承性。

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

建立新的空白記憶體對應檔,或開啟現有的記憶體對應檔 (如果有名稱相同的檔案存在)。 如果開啟現有的檔案,則會忽略容量、選項和記憶體引數。

CreateOrOpen(String, Int64)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱和容量。

CreateOrOpen(String, Int64, MemoryMappedFileAccess)

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量和存取類型。

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

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量、存取類型、記憶體配置、安全性權限以及可繼承性。

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);
[<System.Security.SecurityCritical>]
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.MemoryMappedFiles.MemoryMappedFileOptions * System.IO.MemoryMappedFiles.MemoryMappedFileSecurity * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateOrOpen (mapName As String, capacity As Long, access As MemoryMappedFileAccess, options As MemoryMappedFileOptions, memoryMappedFileSecurity As MemoryMappedFileSecurity, inheritability As HandleInheritability) As MemoryMappedFile

參數

mapName
String

記憶體對應檔的名稱。

capacity
Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。

access
MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。 預設為 ReadWrite

options
MemoryMappedFileOptions

列舉值的位元組合,指定記憶體對應檔的記憶體配置選項。

memoryMappedFileSecurity
MemoryMappedFileSecurity

允許對記憶體對應檔進行檔案存取及作業的可授與權限。

這個參數可以是 null

inheritability
HandleInheritability

其中一個列舉值,決定記憶體對應檔的控制代碼是否可以由子處理序繼承。 預設為 None

傳回

記憶體對應檔,具有指定的特性。

屬性

例外狀況

mapNamenull

mapName 為空字串。

-或-

使用 Write 列舉值,將 access 設為唯寫。

capacity 大於邏輯位址空間的大小。

-或-

capacity 小於或等於零。

-或-

access 不是有效的 MemoryMappedFileAccess 列舉值。

-或-

inheritability 不是有效的 HandleInheritability 列舉值。

作業系統拒絕對檔案進行指定之 access,例如,access 設定為 WriteReadWrite,但是檔案或目錄是唯讀的。

備註

使用這個方法來建立或開啟記憶體對應檔案,該檔案未保存 (,也就是未與磁片) 上的檔案相關聯,您可以使用此檔案在進程之間共用資料。

另請參閱

適用於

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

來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs

建立新的空白記憶體對應檔,或開啟現有的記憶體對應檔 (如果有名稱相同的檔案存在)。 如果開啟現有的檔案,則會忽略容量、選項和記憶體引數。

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);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
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);
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);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess * System.IO.MemoryMappedFiles.MemoryMappedFileOptions * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
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

記憶體對應檔的名稱。

capacity
Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。

access
MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。 預設為 ReadWrite

options
MemoryMappedFileOptions

值的位元組合,指出要套用至檔案的記憶體配置選項。

inheritability
HandleInheritability

決定記憶體對應檔的控制代碼是否可以由子處理序繼承的值。 預設為 None

傳回

記憶體對應檔,具有指定的特性。

屬性

例外狀況

mapNamenull

mapName 為空字串。

-或-

使用 Write 列舉值,將 access 設為唯寫。

capacity 大於邏輯位址空間的大小。

-或-

capacity 小於或等於零。

-或-

access 不是有效的 MemoryMappedFileAccess 列舉值。

-或-

inheritability 不是有效的 HandleInheritability 列舉值。

作業系統拒絕對檔案進行指定之存取,例如,存取設定為 WriteReadWrite,但是檔案或目錄是唯讀的。

適用於

CreateOrOpen(String, Int64)

來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱和容量。

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateOrOpen(System::String ^ mapName, long capacity);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (string mapName, long capacity);
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (string mapName, long capacity);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member CreateOrOpen : string * int64 -> System.IO.MemoryMappedFiles.MemoryMappedFile
static member CreateOrOpen : string * int64 -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function CreateOrOpen (mapName As String, capacity As Long) As MemoryMappedFile

參數

mapName
String

記憶體對應檔的名稱。

capacity
Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。

傳回

記憶體對應檔,具有指定的名稱與大小。

屬性

例外狀況

mapName 為空字串。

capacity 大於邏輯位址空間的大小。

-或-

capacity 小於或等於零。

備註

使用這個方法來建立或開啟記憶體對應檔案,該檔案未保存 (,也就是未與磁片) 上的檔案相關聯,您可以使用此檔案在進程之間共用資料。

另請參閱

適用於

CreateOrOpen(String, Int64, MemoryMappedFileAccess)

來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs
來源:
MemoryMappedFile.cs

建立或開啟記憶體對應檔,此檔案在系統記憶體中具有指定的名稱、容量和存取類型。

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ CreateOrOpen(System::String ^ mapName, long capacity, System::IO::MemoryMappedFiles::MemoryMappedFileAccess access);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.IO.MemoryMappedFiles.MemoryMappedFile CreateOrOpen (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);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member CreateOrOpen : string * int64 * System.IO.MemoryMappedFiles.MemoryMappedFileAccess -> System.IO.MemoryMappedFiles.MemoryMappedFile
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

記憶體對應檔的名稱。

capacity
Int64

要配置給記憶體對應檔的大小上限 (以位元組為單位)。

access
MemoryMappedFileAccess

其中一個列舉值,指定記憶體對應檔允許的存取類型。 預設為 ReadWrite

傳回

記憶體對應檔,具有指定的特性。

屬性

例外狀況

mapNamenull

mapName 為空字串。

-或-

使用 Write 列舉值,將 access 設為唯寫。

capacity 大於邏輯位址空間的大小。

-或-

capacity 小於或等於零。

-或-

access 不是有效的 MemoryMappedFileAccess 列舉值。

作業系統拒絕對檔案進行指定之存取,例如,存取設定為 WriteReadWrite,但是檔案或目錄是唯讀的。

備註

使用這個方法來建立或開啟記憶體對應檔案,該檔案未保存 (,也就是未與磁片) 上的檔案相關聯,您可以使用此檔案在進程之間共用資料。

另請參閱

適用於