Table of Contents

Class InMemoryRandomAccessStream

Namespace
Windows.Storage.Streams
Assembly
Windows.Storage.Streams.dll

Provides random access of data in input and output streams that are stored in memory instead of on disk.

public sealed class InMemoryRandomAccessStream : MarshalByRefObject, IRandomAccessStream, IDisposable, IInputStream, IOutputStream
Inheritance
InMemoryRandomAccessStream
Implements
Inherited Members
Extension Methods

Constructors

InMemoryRandomAccessStream()

Creates a new instance of the InMemoryRandomAccessStream class.

public InMemoryRandomAccessStream()

Properties

CanRead

Gets a value that indicates whether the stream can be read from.

public bool CanRead { get; }

Property Value

bool

True if the stream can be read from. Otherwise, false.

CanWrite

Gets a value that indicates whether the stream can be written to.

public bool CanWrite { get; }

Property Value

bool

True if the stream can be written to. Otherwise, false.

Length

Gets the number of bytes currently in use in the buffer.

public ulong Length { get; }

Property Value

ulong

he number of bytes currently in use in the buffer, which is less than or equal to the capacity of the buffer.

Position

Gets the byte offset of the stream.

public ulong Position { get; }

Property Value

ulong

The number of bytes from the start of the stream.

Remarks

The initial offset of a IRandomAccessStream is 0. This offset is affected by both IInputStream and IOutputStream operations.

Size

Gets or sets the size of the random access stream.

public ulong Size { get; set; }

Property Value

ulong

The size of the stream.

UnstoredBufferLength

Gets the size of the buffer that has not been used.

public uint UnstoredBufferLength { get; set; }

Property Value

uint

The available buffer length, in bytes.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Flush()

Flushes data in a sequential stream.

public bool Flush()

Returns

bool

The stream flush operation.

Remarks

The Flush method may produce latencies and does not always guarantee durable and coherent storage of data. It's generally recommended to avoid this method if possible. This method is specific to nanoFramework. The equivalent method in the UWP API is: FlushAsync.

Read(IBuffer, uint, InputStreamOptions)

Reads data from the stream.

public uint Read(IBuffer buffer, uint count, InputStreamOptions options)

Parameters

buffer IBuffer

A buffer that is used to return the array of bytes that are read. The return value contains the buffer that holds the results.

count uint

The number of bytes to read that is less than or equal to the Capacity value.

options InputStreamOptions

Specifies the type of the asynchronous read operation.

Returns

uint

The number of bytes that were actually read.

Remarks

This method is specific to nanoFramework. The equivalent method in the UWP API is: ReadAsync(IBuffer buffer, UInt32 count, InputStreamOptions options).

Seek(ulong)

Sets the position of the stream to the specified value.

public void Seek(ulong position)

Parameters

position ulong

The new position of the stream.

Remarks

Warning! This method does not check the position to make sure the value is valid for the stream. If the position is invalid for the stream, the ReadAsync and WriteAsync methods will return an error if you call them.

Store()

public uint Store()

Returns

uint

Write(byte[])

Writes data in a sequential stream.

public void Write(byte[] buffer)

Parameters

buffer byte[]

A buffer that contains the data to be written.

Remarks

This method is specific to nanoFramework. The equivalent method in the UWP API is: WriteAsync.