METHOD

HttpContent.ReadAsStreamAsync

Obtains a stream representing HTTP content. Depending on the content implementation it may buffer; it does not guarantee streaming from the network. Read with a separate byte limit and cancellation token. Dispose the owning response after consuming it.

Formal Syntax & Structure

csharp syntaxcsharp
await content.ReadAsStreamAsync(cancellationToken)

Working Example

Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Net;using System.Net.Http;using System.Net.Http.Headers;using System.Threading;using var content = new ByteArrayContent(new byte[]{42});using var stream = await content.ReadAsStreamAsync(CancellationToken.None);Console.WriteLine(stream.ReadByte()); // 42
C# & .NET Reference