MD5 on PNG files & how can I use RandomAccessStreamOverStream in C#?
===

I need to open a file, calculate it's MD5, and then open this as an image if the md5 is correct within a C# Winrt/Metro app.

The problem I have is that the hashing classes in WinRT require IBuffers (as returned from FileIO.ReadBufferAsync(StorageFile) and the image classes require a RandomAccessStream (as returned from StorageFile.OpenReadAsync()).

Obviously I can open the file twice and use both of these calls, but that seems quite inefficient.  Is there a simple way to open the file in such a way that I can pass a stream/IBuffer to both the MD5 HashAlgorithmProvider.HashData() and the BitmapImage.SetSource() function.

I found the RandomAccessStreamOverStream function which I thought I could use to convert the IBuffer.AsStream() but can find no way to instantiate this in C#.

Does anyone have any ideas on the 'correct' way to do this?  I'm new to C# and struggling to come to grips with why there are two seemingly incompatible streaming/buffering concepts in Metro.... :(

