Bewerken

Delen via


WindowsRuntimeStreamExtensions.AsStream Method

Definition

Overloads

AsStream(IRandomAccessStream)

Converts a random access stream in the Windows Runtime to a managed stream in the .NET for Windows Store apps.

AsStream(IRandomAccessStream, Int32)

Converts a random access stream in the Windows Runtime to a managed stream in the .NET for Windows Store apps using the specified buffer size.

AsStream(IRandomAccessStream)

Important

This API is not CLS-compliant.

Converts a random access stream in the Windows Runtime to a managed stream in the .NET for Windows Store apps.

public:
[System::Runtime::CompilerServices::Extension]
 static System::IO::Stream ^ AsStream(Windows::Storage::Streams::IRandomAccessStream ^ windowsRuntimeStream);
[System.CLSCompliant(false)]
public static System.IO.Stream AsStream (this Windows.Storage.Streams.IRandomAccessStream windowsRuntimeStream);
[<System.CLSCompliant(false)>]
static member AsStream : Windows.Storage.Streams.IRandomAccessStream -> System.IO.Stream
<Extension()>
Public Function AsStream (windowsRuntimeStream As IRandomAccessStream) As Stream

Parameters

windowsRuntimeStream
IRandomAccessStream

The Windows Runtime IRandomAccessStream object to convert.

Returns

The converted stream.

Attributes

Exceptions

windowsRuntimeStream is null.

Remarks

Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Stream. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

A default buffer size of 16,384 bytes is used when converting the stream. To specify a different buffer size, use the AsStream(IRandomAccessStream, Int32) overload.

Applies to

AsStream(IRandomAccessStream, Int32)

Important

This API is not CLS-compliant.

Converts a random access stream in the Windows Runtime to a managed stream in the .NET for Windows Store apps using the specified buffer size.

public:
[System::Runtime::CompilerServices::Extension]
 static System::IO::Stream ^ AsStream(Windows::Storage::Streams::IRandomAccessStream ^ windowsRuntimeStream, int bufferSize);
[System.CLSCompliant(false)]
public static System.IO.Stream AsStream (this Windows.Storage.Streams.IRandomAccessStream windowsRuntimeStream, int bufferSize);
[<System.CLSCompliant(false)>]
static member AsStream : Windows.Storage.Streams.IRandomAccessStream * int -> System.IO.Stream
<Extension()>
Public Function AsStream (windowsRuntimeStream As IRandomAccessStream, bufferSize As Integer) As Stream

Parameters

windowsRuntimeStream
IRandomAccessStream

The Windows Runtime IRandomAccessStream object to convert.

bufferSize
Int32

The size, in bytes, of the buffer. This value cannot be negative, but it can be 0 (zero) to disable buffering.

Returns

The converted stream.

Attributes

Exceptions

windowsRuntimeStream is null.

bufferSize is negative.

Remarks

Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Stream. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

You use this method to specify a buffer size when converting the stream. To use the default buffer size of 16,384 bytes, use the AsStream(IRandomAccessStream) overload.

In most situations, buffering improves the performance of stream operations. You can disable buffering by setting bufferSize to zero, but you should do this only when you are sure that disabling buffering is appropriate for your situation.

Applies to