Export (0) Print
Expand All

MemoryMappedViewAccessor Class

Represents a randomly accessed view of a memory-mapped file.

System.Object
  System.IO.UnmanagedMemoryAccessor
    System.IO.MemoryMappedFiles.MemoryMappedViewAccessor

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

public sealed class MemoryMappedViewAccessor : UnmanagedMemoryAccessor

The MemoryMappedViewAccessor type exposes the following members.

  NameDescription
Public propertyCanReadDetermines whether the accessor is readable. (Inherited from UnmanagedMemoryAccessor.)
Public propertyCanWriteDetermines whether the accessory is writable. (Inherited from UnmanagedMemoryAccessor.)
Public propertyCapacityGets the capacity of the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public propertySafeMemoryMappedViewHandleGets a handle to the view of a memory-mapped file.
Top

  NameDescription
Public methodDispose()Releases all resources used by the UnmanagedMemoryAccessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodFlushClears all buffers for this view and causes any buffered data to be written to the underlying file.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodRead<T>Reads a structure of type T from the accessor into a provided reference. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadArray<T>Reads structures of type T from the accessor into an array of type T. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadBooleanReads a Boolean value from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadByteReads a byte value from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadCharReads a character from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadDecimalReads a decimal value from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadDoubleReads a double-precision floating-point value from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadInt16Reads a 16-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadInt32Reads a 32-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadInt64Reads a 64-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadSByteReads an 8-bit signed integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadSingleReads a single-precision floating-point value from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadUInt16Reads an unsigned 16-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadUInt32Reads an unsigned 32-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodReadUInt64Reads an unsigned 64-bit integer from the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWrite(Int64, Boolean)Writes a Boolean value into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Byte)Writes a byte value into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Char)Writes a character into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Decimal)Writes a decimal value into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Double)Writes a Double value into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Int16)Writes a 16-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Int32)Writes a 32-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Int64)Writes a 64-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, SByte)Writes an 8-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, Single)Writes a Single into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, UInt16)Writes an unsigned 16-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, UInt32)Writes an unsigned 32-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite(Int64, UInt64)Writes an unsigned 64-bit integer into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWrite<T>(Int64, T)Writes a structure into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Public methodWriteArray<T>Writes structures from an array of type T into the accessor. (Inherited from UnmanagedMemoryAccessor.)
Top

Use the CreateViewAccessor method of a MemoryMappedFile object to get this view.

The following example obtains a MemoryMappedViewAccessor from a large memory-mapped file for editing.

This code example is part of a larger example provided for the MemoryMappedFile class.

// Create a random access view, from the 256th megabyte (the offset) 
// to the 768th megabyte (the offset plus length). 
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
    int colorSize = Marshal.SizeOf(typeof(MyColor));
    MyColor color;

    // Make changes to the view. 
    for (long i = 0; i < length; i += colorSize)
    {
        accessor.Read(i, out color);
        color.Brighten(10);
        accessor.Write(i, ref color);
    }
}

.NET Framework

Supported in: 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft