WindowsRuntimeStreamExtensions.AsRandomAccessStream(System.IO.Stream) Method

[Supported in the .NET Framework 4.5.1 and later versions]

Converts the specified stream to a random access stream.

Namespace: System.IO
Assembly: System.Runtime.WindowsRuntime (in System.Runtime.WindowsRuntime.dll)

Syntax

[CLSCompliantAttribute(false)]  
public static  IRandomAccessStream AsRandomAccessStream(Stream stream)  
'Declaration  
<ExtensionAttribute> _  
<CLSCompliantAttribute(False)> _  
Public Shared Function AsRandomAccessStream ( _  
        stream As Stream) As IRandomAccessStream  

Parameters

stream

Type: System.IO.Stream
The stream to convert.

Return Value

Type: Windows.Storage.Streams.RandomAccessStream
A Windows Runtime random access stream, which represents the converted stream.

Exceptions

Exception Condition
NotSupportedException The stream to convert does not support seeking.

Remarks

This extension method is available only when you develop Windows Store apps. This method provides a convenient way of working with streams in Windows Store apps. The .NET Framework stream you want to convert must support seeking. For more information, see the Stream.Seek method.

Important

This API is supported in the .NET Framework 4.5.1 and later versions, but not in version 4.5.

Version Information

.NET for Windows Store apps

Supported in: Windows 8.1

See Also

`System.IO.WindowsRuntimeStreamExtensions`

How to: Convert Between .NET Framework Streams and Windows Runtime Streams