Export (0) Print
Expand All

MemoryMappedViewStream Class

Represents a view of a memory-mapped file as a sequentially accessed stream.

System.Object
  System.MarshalByRefObject
    System.IO.Stream
      System.IO.UnmanagedMemoryStream
        System.IO.MemoryMappedFiles.MemoryMappedViewStream

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

public sealed class MemoryMappedViewStream : UnmanagedMemoryStream

The MemoryMappedViewStream type exposes the following members.

  NameDescription
Public propertyCanReadGets a value indicating whether a stream supports reading. (Inherited from UnmanagedMemoryStream.)
Public propertyCanSeekGets a value indicating whether a stream supports seeking. (Inherited from UnmanagedMemoryStream.)
Public propertyCanTimeoutGets a value that determines whether the current stream can time out. (Inherited from Stream.)
Public propertyCanWriteGets a value indicating whether a stream supports writing. (Inherited from UnmanagedMemoryStream.)
Public propertyCapacityGets the stream length (size) or the total amount of memory assigned to a stream (capacity). (Inherited from UnmanagedMemoryStream.)
Public propertyLengthGets the length of the data in a stream. (Inherited from UnmanagedMemoryStream.)
Public propertyPointerOffset[Supported in the .NET Framework 4.5.1 and later versions] Gets the number of bytes by which the starting position of this view is offset from the beginning of the memory-mapped file.
Public propertyPositionGets or sets the current position in a stream. (Inherited from UnmanagedMemoryStream.)
Public propertyPositionPointerGets or sets a byte pointer to a stream based on the current position in the stream. (Inherited from UnmanagedMemoryStream.)
Public propertyReadTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from Stream.)
Public propertySafeMemoryMappedViewHandleGets a handle to the view of a memory-mapped file.
Public propertyWriteTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from Stream.)
Top

  NameDescription
Public methodBeginReadBegins an asynchronous read operation. (Consider using ReadAsync instead; see the Remarks section.) (Inherited from Stream.)
Public methodBeginWriteBegins an asynchronous write operation. (Consider using WriteAsync instead; see the Remarks section.) (Inherited from Stream.)
Public methodCloseCloses the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Instead of calling this method, ensure that the stream is properly disposed. (Inherited from Stream.)
Public methodCopyTo(Stream)Reads the bytes from the current stream and writes them to another stream. (Inherited from Stream.)
Public methodCopyTo(Stream, Int32)Reads the bytes from the current stream and writes them to another stream, using a specified buffer size. (Inherited from Stream.)
Public methodCopyToAsync(Stream)Asynchronously reads the bytes from the current stream and writes them to another stream. (Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size. (Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32, CancellationToken)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token. (Inherited from Stream.)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by the Stream. (Inherited from Stream.)
Public methodEndReadWaits for the pending asynchronous read to complete. (Consider using ReadAsync instead; see the Remarks section.) (Inherited from Stream.)
Public methodEndWriteEnds an asynchronous write operation. (Consider using WriteAsync instead; see the Remarks section.) (Inherited from Stream.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodFlushClears all buffers for this stream and causes any buffered data to be written to the underlying file. (Overrides UnmanagedMemoryStream.Flush().)
Public methodFlushAsync()Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from Stream.)
Public methodFlushAsync(CancellationToken)Overrides the Stream.FlushAsync method so that the operation is cancelled if specified, but no other action is performed.Available starting in .NET Framework 2015 (Inherited from UnmanagedMemoryStream.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodReadReads the specified number of bytes into the specified array. (Inherited from UnmanagedMemoryStream.)
Public methodReadAsync(Byte[], Int32, Int32)Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from Stream.)
Public methodReadAsync(Byte[], Int32, Int32, CancellationToken)Asynchronously reads the specified number of bytes into the specified array.Available starting in .NET Framework 2015 (Inherited from UnmanagedMemoryStream.)
Public methodReadByteReads a byte from a stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from UnmanagedMemoryStream.)
Public methodSeekSets the current position of the current stream to the given value. (Inherited from UnmanagedMemoryStream.)
Public methodSetLengthInfrastructure. Sets the length of the current stream. (Overrides UnmanagedMemoryStream.SetLength(Int64).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteWrites a block of bytes to the current stream using data from a buffer. (Inherited from UnmanagedMemoryStream.)
Public methodWriteAsync(Byte[], Int32, Int32)Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from Stream.)
Public methodWriteAsync(Byte[], Int32, Int32, CancellationToken)Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.Available starting in .NET Framework 2015 (Inherited from UnmanagedMemoryStream.)
Public methodWriteByteWrites a byte to the current position in the file stream. (Inherited from UnmanagedMemoryStream.)
Top

Use the CreateViewStream method of a MemoryMappedFile object to get this stream.

The following example obtains a MemoryMappedViewStream of a memory-mapped file and writes a value to the stream for inter-process communication.

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

using (MemoryMappedViewStream stream = mmf.CreateViewStream())
{
    BinaryWriter writer = new BinaryWriter(stream);
    writer.Write(1);
}

.NET Framework

Supported in: 4.5.3, 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