System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile Method

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

Syntax

public static MemoryMappedFile CreateFromFile (string path, System.IO.FileMode mode, string mapName, long capacity)

Parameters

path
The path to the file to map.
mode
Access mode; can be any of the System.IO.FileMode enumeration values except System.IO.FileMode.Append.
mapName
A name to assign to the memory-mapped file.
capacity
The maximum size, in bytes, to allocate to the memory-mapped file. Specify 0 to set the capacity to the size of the file on disk.

Returns

A memory-mapped file that has the specified characteristics.

Remarks

The mode parameter pertains to the source file on disk.

If capacity is larger than the size of the file on disk, the file on disk is increased to match the specified capacity even if no data is written to the memory-mapped file. To prevent this from occurring, specify 0 (zero) for the default capacity, which will internally set capacity to the size of the file on disk.

Requirements

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