Export (0) Print
Expand All

MemoryMappedFile.CreateFromFile Method (String, FileMode)

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

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

static member CreateFromFile : 
        path:string * 
        mode:FileMode -> MemoryMappedFile

Parameters

path
Type: System.String

The path to file to map.

mode
Type: System.IO.FileMode

Access mode; must be Open.

Return Value

Type: System.IO.MemoryMappedFiles.MemoryMappedFile
A memory-mapped file that has the specified access mode.

ExceptionCondition
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-

mode is Append.

ArgumentNullException

path is a null reference (Nothing in Visual Basic).

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

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft