Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading file content to string in .Net Compact Framework

I am developing an application for mobile devices with the .net compact framework 2.0. I am trying to load a file's content to a string object, but somehow I can't get it done. There is no ReadToEnd() method in the System.IO.StreamReader class. Is there another class that provides this functionality?

like image 353
lng Avatar asked Jul 27 '11 20:07

lng


1 Answers

StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader("TestFile.txt"))  {     String line;     // Read and display lines from the file until the end of      // the file is reached.     while ((line = sr.ReadLine()) != null)      {         sb.AppendLine(line);     } } string allines = sb.ToString(); 
like image 151
Jethro Avatar answered Sep 18 '22 23:09

Jethro