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?


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();

string text = string.Empty;
using (StreamReader streamReader = new StreamReader(filePath, Encoding.UTF8))
{            
    text = streamReader.ReadToEnd();
}

Another option:

string[] lines = File.ReadAllLines("file.txt");

https://gist.github.com/paulodiogo/9134300

Simple!


File.ReadAllText(file) what you're looking for?

There's also File.ReadAllLines(file) if you prefer it broken down in to an array by line.