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

返回

具有指定特征的内存映射文件。

属性

例外

mapName 上声明的默认值为 null

mapName 是一个空字符串。

- 或 -

通过 Write 枚举值将 access 设置为只写。

capacity 大于逻辑地址空间的大小。

- 或 -

capacity 小于或等于零。

- 或 -

access 不是有效的 MemoryMappedFileAccess 枚举值。

- 或 -

inheritability 不是有效的 HandleInheritability 枚举值。

操作系统不允许对文件的指定 access;例如,access 设置为 WriteReadWrite,但文件或目录为只读。

注解

使用此方法创建或打开一个内存映射文件,该文件不是持久化 (,即与磁盘) 上的文件关联,可用于在进程之间共享数据。

另请参阅

适用于

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

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
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

返回

具有指定特征的内存映射文件。

属性

例外

mapName 上声明的默认值为 null

mapName 是一个空字符串。

- 或 -

通过 Write 枚举值将 access 设置为只写。

capacity 大于逻辑地址空间的大小。

- 或 -

capacity 小于或等于零。

- 或 -

access 不是有效的 MemoryMappedFileAccess 枚举值。

- 或 -

inheritability 不是有效的 HandleInheritability 枚举值。

操作系统不允许对文件的指定访问;例如,访问权限设置为 WriteReadWrite,但文件或目录为只读。

适用于

CreateOrOpen(String, Int64)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
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)

Source:
MemoryMappedFile.cs
Source:
MemoryMappedFile.cs
Source:
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

返回

具有指定特征的内存映射文件。

属性

例外

mapName 上声明的默认值为 null

mapName 是一个空字符串。

- 或 -

通过 Write 枚举值将 access 设置为只写。

capacity 大于逻辑地址空间的大小。

- 或 -

capacity 小于或等于零。

- 或 -

access 不是有效的 MemoryMappedFileAccess 枚举值。

操作系统不允许对文件的指定访问;例如,访问权限设置为 WriteReadWrite,但文件或目录为只读。

注解

使用此方法创建或打开一个内存映射文件,该文件不是持久化 (,即与磁盘) 上的文件关联,可用于在进程之间共享数据。

另请参阅

适用于