I want to assign the contents of a text file to a textbox, like so:
String logDirPath =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
String fullPath = logDirPath + "\\application.log";
textBoxErrLogsContents.Text = File.ReadAllText(fullPath);
I got the "ReadAllText" from here, but it's not available to me.
I am referencing mscorlib, and I did add a "using System.IO;" but it's grayed out, while ReadAllText is fire-engine red.
Am I missing something, or do I have to skin this cat some other way in this Windows CE / Compact Framework app?
The compact-framework edition does not implement it. The .net version, however, is simply implemented like this:
public static class File
{
public static String ReadAllText(String path)
{
using (var sr = new StreamReader(path, Encoding.UTF8))
{
return sr.ReadToEnd();
}
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments