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

Definition

Creates or opens a memory-mapped file in system memory.

Overloads

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

Parameters

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. The 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. The default is None.

Returns

A memory-mapped file that has the specified characteristics.

Exceptions

mapName is an empty string.

-or-

access is set to write-only with the Write enumeration value.

capacity is greater than the size of the logical address space.

-or-

capacity is less than or equal to zero.

-or-

access is not a valid MemoryMappedFileAccess enumeration value.

-or-

inheritability is not a valid HandleInheritability enumeration value.

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

Parameters

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. The 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.

This 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. The default is None.

Returns

A memory-mapped file that has the specified characteristics.

Exceptions

mapName is an empty string.

-or-

access is set to write-only with the Write enumeration value.

capacity is greater than the size of the logical address space.

-or-

capacity is less than or equal to zero.

-or-

access is not a valid MemoryMappedFileAccess enumeration value.

-or-

inheritability is not a valid HandleInheritability enumeration value.

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.

Remarks

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.

Security

SecurityPermission
for access to unmanaged code. Associated enumeration: UnmanagedCode.

See Also

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

Parameters

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.

Returns

A memory-mapped file that has the specified name and size.

Exceptions

capacity is greater than the size of the logical address space.

-or-

capacity is less than or equal to zero.

Remarks

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.

See Also

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

Parameters

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. The default is ReadWrite.

Returns

A memory-mapped file that has the specified characteristics.

Exceptions

mapName is an empty string.

-or-

access is set to write-only with the Write enumeration value.

capacity is greater than the size of the logical address space.

-or-

capacity is less than or equal to zero.

-or-

access is not a valid MemoryMappedFileAccess enumeration value.

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.

Remarks

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.

See Also

Applies to