MemoryMappedFile Class

.NET Framework (current version)
 

Represents a memory-mapped file.

Namespace:   System.IO.MemoryMappedFiles
Assembly:  System.Core (in System.Core.dll)

System::Object
  System.IO.MemoryMappedFiles::MemoryMappedFile

public ref class MemoryMappedFile : IDisposable

NameDescription
System_CAPS_pubpropertySafeMemoryMappedFileHandle

Gets the file handle of a memory-mapped file.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(FileStream^, String^, Int64, MemoryMappedFileAccess, HandleInheritability, Boolean)

Creates a memory-mapped file from an existing file with the specified access mode, name, inheritability, and capacity.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(FileStream^, String^, Int64, MemoryMappedFileAccess, MemoryMappedFileSecurity^, HandleInheritability, Boolean)

Creates a memory-mapped file that has the specified name, capacity, access type, security permissions, inheritability, and disposal requirement from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(String^)

Creates a memory-mapped file from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(String^, FileMode)

Creates a memory-mapped file that has the specified access mode from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(String^, FileMode, String^)

Creates a memory-mapped file that has the specified access mode and name from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(String^, FileMode, String^, Int64)

Creates a memory-mapped file that has the specified access mode, name, and capacity from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateFromFile(String^, FileMode, String^, Int64, MemoryMappedFileAccess)

Creates a memory-mapped file that has the specified access mode, name, capacity, and access type from a file on disk.

System_CAPS_pubmethodSystem_CAPS_staticCreateNew(String^, Int64)

Creates a memory-mapped file that has the specified capacity in system memory.

System_CAPS_pubmethodSystem_CAPS_staticCreateNew(String^, Int64, MemoryMappedFileAccess)

Creates a memory-mapped file that has the specified capacity and access type in system memory.

System_CAPS_pubmethodSystem_CAPS_staticCreateNew(String^, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, HandleInheritability)

Creates a memory-mapped file that has the specified name, capacity, access type, memory allocation options and inheritability.

System_CAPS_pubmethodSystem_CAPS_staticCreateNew(String^, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity^, HandleInheritability)

Creates a memory-mapped file that has the specified capacity, access type, memory allocation, security permissions, and inheritability in system memory.

System_CAPS_pubmethodSystem_CAPS_staticCreateOrOpen(String^, Int64)

Creates or opens a memory-mapped file that has the specified capacity in system memory.

System_CAPS_pubmethodSystem_CAPS_staticCreateOrOpen(String^, Int64, MemoryMappedFileAccess)

Creates or opens a memory-mapped file that has the specified capacity and access type in system memory.

System_CAPS_pubmethodSystem_CAPS_staticCreateOrOpen(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.

System_CAPS_pubmethodSystem_CAPS_staticCreateOrOpen(String^, Int64, MemoryMappedFileAccess, MemoryMappedFileOptions, MemoryMappedFileSecurity^, HandleInheritability)

Creates or opens a memory-mapped file that has the specified capacity, access type, memory allocation, security permissions, and inheritability in system memory.

System_CAPS_pubmethodCreateViewAccessor()

Creates a MemoryMappedViewAccessor that maps to a view of the memory-mapped file.

System_CAPS_pubmethodCreateViewAccessor(Int64, Int64)

Creates a MemoryMappedViewAccessor that maps to a view of the memory-mapped file, and that has the specified offset and size.

System_CAPS_pubmethodCreateViewAccessor(Int64, Int64, MemoryMappedFileAccess)

Creates a MemoryMappedViewAccessor that maps to a view of the memory-mapped file, and that has the specified offset, size, and access restrictions.

System_CAPS_pubmethodCreateViewStream()

Creates a stream that maps to a view of the memory-mapped file.

System_CAPS_pubmethodCreateViewStream(Int64, Int64)

Creates a stream that maps to a view of the memory-mapped file, and that has the specified offset and size.

System_CAPS_pubmethodCreateViewStream(Int64, Int64, MemoryMappedFileAccess)

Creates a stream that maps to a view of the memory-mapped file, and that has the specified offset, size, and access type.

System_CAPS_pubmethodDispose()

Releases all resources used by the MemoryMappedFile.

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the MemoryMappedFile and optionally releases the managed resources.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetAccessControl()

Gets the access control to the memory-mapped file resource.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticOpenExisting(String^)

Opens an existing memory-mapped file that has the specified name in system memory.

System_CAPS_pubmethodSystem_CAPS_staticOpenExisting(String^, MemoryMappedFileRights)

Opens an existing memory-mapped file that has the specified name and access rights in system memory.

System_CAPS_pubmethodSystem_CAPS_staticOpenExisting(String^, MemoryMappedFileRights, HandleInheritability)

Opens an existing memory-mapped file that has the specified name, access rights, and inheritability in system memory.

System_CAPS_pubmethodSetAccessControl(MemoryMappedFileSecurity^)

Sets the access control to the memory-mapped file resource.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

A memory-mapped file maps the contents of a file to an application’s logical address space. Memory-mapped files enable programmers to work with extremely large files because memory can be managed concurrently, and they allow complete, random access to a file without the need for seeking. Memory-mapped files can also be shared across multiple processes.

The CreateFromFile methods create a memory-mapped file from a specified path or a FileStream of an existing file on disk. Changes are automatically propagated to disk when the file is unmapped.

The CreateNew methods create a memory-mapped file that is not mapped to an existing file on disk; and are suitable for creating shared memory for interprocess communication (IPC).

A memory-mapped file is associated with a name.

You can create multiple views of the memory-mapped file, including views of parts of the file. You can map the same part of a file to more than one address to create concurrent memory. For two views to remain concurrent, they have to be created from the same memory-mapped file. Creating two file mappings of the same file with two views does not provide concurrency.

The following example creates a memory-mapped view of a part of an extremely large file and manipulates a portion of it.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: