michielpost.nl

Reading and writing files in WinRT

10-07-2012

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);
reader.DetachStream();

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

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:
http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html


 

Comments


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. https://helloworld.com?h=d94ec48e54d570739ad55dac502a35c3& 19-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. https://helloworld.com?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3& 19-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3& 20-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3& 20-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3& 20-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3& 21-11-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. http://bit.do/fLc9r?h=d94ec48e54d570739ad55dac502a35c3&


???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. https://helloworld.com?h=d94ec48e54d570739ad55dac502a35c3& 04-12-2020
???????? ?? ? ????, ????? ???????? ??????, ? ? ????, ????? ???? ????? ????? ?????. https://helloworld.com?h=d94ec48e54d570739ad55dac502a35c3&


Buy legal anabolic steroids https://myfsk.org/community/account/buy-legal-anabolic-steroids/?h=d94ec48e54d570739ad55dac502a35c3& 13-12-2020
Buy legal anabolic steroids https://myfsk.org/community/account/buy-legal-anabolic-steroids/?h=d94ec48e54d570739ad55dac502a35c3&


<p><a href="https://f3gxp.page.link/Tbeh"><img src="https://i.ibb.co/rH6Ky7F/best-hookup-sites-fs.jpg"></a></p>?h=d94ec48e54d570739ad55dac502a35c3& 20-12-2020
<p><a href="https://f3gxp.page.link/Tbeh"><img src="https://i.ibb.co/rH6Ky7F/best-hookup-sites-fs.jpg"></a></p>?h=d94ec48e54d570739ad55dac502a35c3&


<p><a href="https://f3gxp.page.link/Tbeh"><img src="https://i.ibb.co/rH6Ky7F/best-hookup-sites-fs.jpg"></a></p>?h=d94ec48e54d570739ad55dac502a35c3& 21-12-2020
<p><a href="https://f3gxp.page.link/Tbeh"><img src="https://i.ibb.co/rH6Ky7F/best-hookup-sites-fs.jpg"></a></p>?h=d94ec48e54d570739ad55dac502a35c3&


RklGO 10-01-2021
Meds information sheet. Brand names. <a href="https://viagra4u.top">can you buy generic viagra pill</a> in the USA. All about medicines. Read here. <a href=https://www.dobrogea.tv/index.php?display=stire&categorie=Actualitate&id=14906&title=constanta-asociatiile-de-proprietari-care-risca-sa-ramana-fara-apa-calda-si-caldura-daca-nusi-achita-restantele-lista-completa#comentarii>All trends of pills.</a> <a href=http://www.ggtronics.com/ticket-submitted.php?id=NDY1Njg=>All about pills.</a> <a href=https://filmshalatv.com/post/1950>Everything information about meds.</a> c84bc8a


New Comment

Name
E-mail (not published)
Comment
Enter the code shown: