How to get a stream from a byte array in a windows8 store app

前端 未结 3 937
南旧
南旧 2021-01-16 01:02

I have been trying get a stream from a byte array in metro style app using the following code.

InMemoryRandomAccessStream memoryStream = new InMemoryRandomAc         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-16 01:42

    I know this is a very old question, but I was running into this issue myself today and figured it out so I'll leave this here for others.

    I realized that the stream wasn't being written if it was too small. To fix this, I explicitly set the length of the stream like this:

    ms.AsStreamForWrite(imageBytes.Length).Write(imageBytes, 0, imageBytes.Length);
    

    That should be all you need.

提交回复
热议问题