The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Downloading and reading a .txt file from a HTTP source RRS feed

  • Question

  • I want to download a .txt file from a HTTP source and save it to a folder with other .txt files already on the phone. I want this downloaded .txt file to stay on the phone's local storage so I can read it after the app has been re-opened.

    How would I go about doing this?

    Friday, June 21, 2013 3:44 PM

All replies

  • that should help

    http://social.msdn.microsoft.com/Forums/wpapps/en-US/06469cfa-ebc2-40b8-aa0d-424c09b7a450/how-to-read-a-txt-from-http

    same principle just based on a windows store app, but the code should work nonetheless you can write the file to a folder in your app's install folder and do the read from there as well or just write to the root of the install folder your choice in the end.

    write performance might be a little weak, might want to convert it to something like json or a database.


    Morgan Vermef


    • Edited by mvermef Friday, June 21, 2013 5:56 PM added content
    Friday, June 21, 2013 5:55 PM
  • HTTPClient() isn't available for Windows Phone? I'm not getting any option to use an appropriate namespace?
    Friday, June 21, 2013 7:24 PM
  • You need to add Microsoft's HTTP Client Libraries.
    Friday, June 21, 2013 8:10 PM
  •  WebClient.DownloadStringAsync does what you want.

    When you have the response (assuming the .txt is text, of course) just use IsolatedStorageFileStream to write the file to iso storage.

    If you need to read a binary file, use HTTPWebRequest instead.


    Darin R.

    Thursday, June 27, 2013 2:38 PM