MemoryMappedFileStatic: CreateFromFile |
Creates a memory-mapped file that has the specified access mode, name, capacity, and access type from a file on disk.
Public Function CreateFromFile( ByRef Path As String, Optional ByVal Mode As FileMode = FileMode. OpenExisting, Optional ByRef MapName As String, Optional ByVal Capacity As Currency, Optional ByVal Access As MemoryMappedFileAccess = MemoryMappedFileAccess. ReadWrite ) As MemoryMappedFile
Default: FileMode . OpenExisting
Default: MemoryMappedFileAccess . ReadWrite
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.
Exception | Condition |
---|---|
ArgumentException |
MapName is an empty string. -or- Access is not an allowed value. -or- Path specifies an empty file. -or- Access is specified as ReadOnly and Capacity is greater than the size of the file indicated by Path. -or- Mode is Append. |
ArgumentOutOfRangeException |
Capacity is less than zero. -or- Capacity is less than the file size (but not zero). -or- Capacity is zero, and the size of the file on disk is also zero. -or- Access is not a defined MemoryMappedFileAccess value. -or- The size of the file indicated by Path is greater than Capacity. |