MemoryMappedFileStatic: CreateFromFileStream |
Creates a memory-mapped file that has the specified name, capacity, access type, and disposal requirement from a file on disk.
Public Function CreateFromFileStream( ByVal FileStream As FileStream, ByRef MapName As String, ByVal Capacity As Currency, ByVal Access As MemoryMappedFileAccess, ByVal LeaveOpen As Boolean ) As MemoryMappedFile
This parameter cant be set to WriteOnly.
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- Capacity and the length of the file are zero. -or- Access is set to the WriteOnly enumeration value, which is not allowed. -or- Access> is set to the ReadOnly enumeration value and Capacity is larger than file size. |
ArgumentNullException | FileStream is Nothing. |
ArgumentOutOfRangeException |
Capacity is less than zero. -or- Capacity is less than the file size. -or- Access is not a valid MemoryMappedFileAccess enumeration value. |
ObjectDisposedException | FileStream was closed. |
IOException | MapName already exists. |