Windows 8 Release Preview – back to earth

6/28/2012 By Marco Kesseler 0 comments

Workaround

Hurray, we got a workaround for the problem of the previous blog. This works:

1 IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read); 2 3 for (ulong i = 0; i < stream.Size; i++) 4 { 5 stream.Seek(i); 6 7 byte[] data = new byte[1]; 8 9 await stream.ReadAsync(data.AsBuffer(), 1, InputStreamOptions.None); 10 11 if (stream.Position > stream.Size) 12 { 13 // Never happens, which is as expected. 14 15 } 16 17 }

The credits for finding this go to Gionata from paperlit.com. Thanks!

Note that the main difference appears to be:

1 IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);

As opposed to:

1 Stream stream = await file.OpenStreamForReadAsync();

Weird, eh? One would say that both expressions are basically synonymous.Well, this means back to work, were it not for the summer holidays…