FileRandomAccessStream FileRandomAccessStream FileRandomAccessStream FileRandomAccessStream Class

Definition

Supports reading and writing to a file at a specified position.

public sealed class FileRandomAccessStreampublic sealed class FileRandomAccessStreamPublic NotInheritable Class FileRandomAccessStreampublic sealed class FileRandomAccessStream
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

CanRead CanRead CanRead CanRead

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

public bool CanRead { get; }public bool CanRead { get; }Public ReadOnly Property CanRead As boolpublic bool CanRead { get; }
Value
bool bool bool bool

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

CanWrite CanWrite CanWrite CanWrite

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

public bool CanWrite { get; }public bool CanWrite { get; }Public ReadOnly Property CanWrite As boolpublic bool CanWrite { get; }
Value
bool bool bool bool

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Position Position Position Position

Gets the byte offset of the stream.

public ulong Position { get; }public ulong Position { get; }Public ReadOnly Property Position As ulongpublic ulong Position { get; }
Value
ulong ulong ulong ulong

The number of bytes from the start of the stream.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Size Size Size Size

Gets or sets the size of the random access stream.

public ulong Size { get; set; }public ulong Size { get; set; }Public ReadWrite Property Size As ulongpublic ulong Size { get; set; }
Value
ulong ulong ulong ulong

The size of the stream.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

CloneStream() CloneStream() CloneStream() CloneStream()

Creates a new instance of a IRandomAccessStream over the same resource as the current stream.

public IRandomAccessStream CloneStream()public IRandomAccessStream CloneStream()Public Function CloneStream() As IRandomAccessStreampublic IRandomAccessStream CloneStream()
Returns

The new stream. The initial, internal position of the stream is 0.

The internal position and lifetime of this new stream are independent from the position and lifetime of the cloned stream.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Close() Close() Close() Close()

Closes the current stream and releases system resources.

public void Close()public void Close()Public Function Close() As voidpublic void Close()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

Flushes data asynchronously in a sequential stream.

public IAsyncOperation<bool> FlushAsync()public IAsyncOperation<bool> FlushAsync()Public Function FlushAsync() As IAsyncOperation( Of bool )public IAsyncOperation<bool> FlushAsync()
Returns

The stream flush operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetInputStreamAt(UInt64) GetInputStreamAt(UInt64) GetInputStreamAt(UInt64) GetInputStreamAt(UInt64)

Returns an input stream at a specified location in a stream.

public IInputStream GetInputStreamAt(UInt64 position)public IInputStream GetInputStreamAt(UInt64 position)Public Function GetInputStreamAt(position As UInt64) As IInputStreampublic IInputStream GetInputStreamAt(UInt64 position)
Parameters
position
System.UInt64 System.UInt64 System.UInt64 System.UInt64

The location in the stream at which to begin.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64) GetOutputStreamAt(UInt64)

Returns an output stream at a specified location in a stream.

public IOutputStream GetOutputStreamAt(UInt64 position)public IOutputStream GetOutputStreamAt(UInt64 position)Public Function GetOutputStreamAt(position As UInt64) As IOutputStreampublic IOutputStream GetOutputStreamAt(UInt64 position)
Parameters
position
System.UInt64 System.UInt64 System.UInt64 System.UInt64

The location in the output stream at which to begin.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions) ReadAsync(IBuffer, UInt32, InputStreamOptions)

Returns an asynchronous byte reader object.

public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, UInt32 count, InputStreamOptions options)public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, UInt32 count, InputStreamOptions options)Public Function ReadAsync(buffer As IBuffer, count As UInt32, options As InputStreamOptions) As IAsyncOperationWithProgress( Of IBuffer, uint )public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, UInt32 count, InputStreamOptions options)
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The buffer into which the asynchronous read operation places the bytes that are read.

count
System.UInt32 System.UInt32 System.UInt32 System.UInt32

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

options
InputStreamOptions InputStreamOptions InputStreamOptions InputStreamOptions

Specifies the type of the asynchronous read operation.

Returns

The asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Seek(UInt64) Seek(UInt64) Seek(UInt64) Seek(UInt64)

Sets the position of the stream to the specified value.

public void Seek(UInt64 position)public void Seek(UInt64 position)Public Function Seek(position As UInt64) As voidpublic void Seek(UInt64 position)
Parameters
position
System.UInt64 System.UInt64 System.UInt64 System.UInt64

The new position of the stream.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer)

Writes data asynchronously to a file.

public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)Public Function WriteAsync(buffer As IBuffer) As IAsyncOperationWithProgress( Of uint, uint )public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The buffer into which the asynchronous writer operation writes.

Returns

The byte writer operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)