Close

.NET Framework Streams to Windows Runtime Streams

Este problema me surgió cuando estaba utilizando un Stream de  HttpCliente (Windows Runtime Streams) he intentado hacer un .AsRandomAccessStream()

Pero no es compatible con operaciones para .NET memory stream

Aquí el código.

 public async Task<IRandomAccessStream> ToRuntimeRandomAccessStream(Uri uriLocation)
        {           
            var stream = await this.GetStreamFromUrl(uriLocation);

            // Create a .NET memory stream.
            var memStream = new MemoryStream();

            // Convert the stream to the memory stream, because a memory stream supports seeking.
            await stream.CopyToAsync(memStream);

            // Set the start position.
            memStream.Position = 0;

            return memStream.AsRandomAccessStream();
       }

La solución la encontré en MSDN.

https://msdn.microsoft.com/en-us/library/dn531021(v=vs.110).aspx

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2021 vladymix | WordPress Theme: Annina Free by CrestaProject.