Posted By

vhdm on 08/05/14


Tagged

phone window xml read external texttxt


Versions (?)

read txt file with windows phone


 / Published in: C#
 

Note: change build Action of file to resource

  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  

You need to login to post a comment.