Is there a way to convert a System.IO.Stream to a Windows.Storage.Streams.IRandomAccessStream?

后端 未结 7 934
暖寄归人
暖寄归人 2020-11-30 00:42

In Windows 8; I would like to pass the contents of a MemoryStream to a class that accepts a parameter of type Windows.Storage.Streams.IRandomAccessStream. Is there any way t

相关标签:
7条回答
  • 2020-11-30 01:11

    There is no built-in way method on Windows 8. For Windows 8.1 we added a Stream.AsRandomAccessStream() extension method:

    internal static IRandomAccessStream ToRandomAccessStream(byte[] array)
    {
        MemoryStream stream = new MemoryStream(array);
        return stream.AsRandomAccessStream();
    }
    
    0 讨论(0)
提交回复
热议问题