Class InMemoryRandomAccessStream
Provides random access of data in input and output streams that are stored in memory instead of on disk.
Inherited Members
Namespace: Windows.Storage.Streams
Assembly: Windows.Storage.Streams.dll
Syntax
public sealed class InMemoryRandomAccessStream : MarshalByRefObject, IRandomAccessStream, IDisposable, IInputStream, IOutputStream
Constructors
InMemoryRandomAccessStream()
Creates a new instance of the InMemoryRandomAccessStream class.
Declaration
public InMemoryRandomAccessStream()
Properties
CanRead
Gets a value that indicates whether the stream can be read from.
Declaration
public bool CanRead { get; }
Property Value
Type | Description |
---|---|
bool | True if the stream can be read from. Otherwise, false. |
CanWrite
Gets a value that indicates whether the stream can be written to.
Declaration
public bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool | True if the stream can be written to. Otherwise, false. |
Length
Gets the number of bytes currently in use in the buffer.
Declaration
public ulong Length { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
public ulong Position { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
public ulong Size { get; set; }
Property Value
Type | Description |
---|---|
ulong | The size of the stream. |
UnstoredBufferLength
Gets the size of the buffer that has not been used.
Declaration
public uint UnstoredBufferLength { get; set; }
Property Value
Type | Description |
---|---|
uint | The available buffer length, in bytes. |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Flush()
Flushes data in a sequential stream.
Declaration
public bool Flush()
Returns
Type | Description |
---|---|
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.
Declaration
public uint Read(IBuffer buffer, uint count, InputStreamOptions options)
Parameters
Type | Name | Description |
---|---|---|
IBuffer | buffer | A buffer that is used to return the array of bytes that are read. The return value contains the buffer that holds the results. |
uint | count | The number of bytes to read that is less than or equal to the Capacity value. |
InputStreamOptions | options | Specifies the type of the asynchronous read operation. |
Returns
Type | Description |
---|---|
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.
Declaration
public void Seek(ulong position)
Parameters
Type | Name | Description |
---|---|---|
ulong | position | 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()
Declaration
public uint Store()
Returns
Type | Description |
---|---|
uint |
Write(byte[])
Writes data in a sequential stream.
Declaration
public void Write(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | 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.