read txt file with windows phone


/ Published in: C#
Save to your folder(s)

Note: change build Action of file to resource


Copy this code and paste it in your HTML
  1. private string ReadFile(string filePath)
  2. {
  3. //this verse is loaded for the first time so fill it from the text file
  4. var ResrouceStream = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));
  5. if (ResrouceStream != null)
  6. {
  7. Stream myFileStream = ResrouceStream.Stream;
  8. if (myFileStream.CanRead)
  9. {
  10. StreamReader myStreamReader = new StreamReader(myFileStream);
  11.  
  12. //read the content here
  13. return myStreamReader.ReadToEnd();
  14. }
  15. }
  16. return "NULL";
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.