使用windows phone读取txt文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用windows phone读取txt文件相关的知识,希望对你有一定的参考价值。

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. }

以上是关于使用windows phone读取txt文件的主要内容,如果未能解决你的问题,请参考以下文章