During the development of my first Windows 8 app, I searched for code examples on how to read and write files to the application storage.

I found a few examples, but they were all so complex.

Complex example of reading file data:
var inStream = readStream.GetInputStreamAt(0);
Windows.Storage.Streams.DataReader reader = new Windows.Storage.Streams.DataReader(inStream);
await reader.LoadAsync((uint)readStream.Size);
string data = reader.ReadString((uint)readStream.Size);

This complex code is used in various open source libraries, like the WinRT XAML Toolkit http://winrtxamltoolkit.codeplex.com/
and Generic Object Storage project:
and the XAML Metro app storage helper:

We don't need so many lines of code!

Today I finally found a really easy example that uses Windows.Storage.FileIO
var data = await FileIO.ReadTextAsync(file);

That was easy!

Jerry Nixon has a great overview on reading and writing files in WinRT on his blog: