MemoryMappedFile.CreateFromFile Method (String, FileMode, String)

.NET Framework (current version)
 

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

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

public static MemoryMappedFile CreateFromFile(
	string path,
	FileMode mode,
	string mapName
)

Parameters

path
Type: System.String

The path to the file to map.

mode
Type: System.IO.FileMode

Access mode; must be Open.

mapName
Type: System.String

A name to assign to the memory-mapped file.

Return Value

Type: System.IO.MemoryMappedFiles.MemoryMappedFile

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

Exception Condition
ArgumentException

path is an empty string, contains only white space, or has one or more invalid characters, as defined by the Path.GetInvalidFileNameChars method.

-or-

path refers to an invalid device.

-or-

mapName is an empty string.

-or-

mode is Append.

ArgumentNullException

path or mapName is null.

IOException

mode is Create, CreateNew, or Truncate.

-or-

mode is OpenOrCreate and the file on disk does not exist.

-or-

An I/O error occurred.

PathTooLongException

path exceeds the maximum length defined by the operating system. In Windows, paths must contain fewer than 248 characters, and file names must contain fewer than 260 characters.

SecurityException

The caller does not have the required permissions for the file.

The mode parameter pertains to the source file on disk. You can use only the Open enumeration value to create the memory-mapped file from the source file on disk.

.NET Framework
Available since 4.0
Return to top
Show: