Creates a
StreamReader with UTF8 encoding that reads from an existing
text file.
Namespace: Crestron.SimplSharp.CrestronIOAssembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
Exceptions
Example
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;;
class Test
{
public static void Main()
{
string path = @"\User\MyTest.txt";
FileInfo fi = new FileInfo(path);
// Check for existing file
if (!fi.Exists)
{
// Create the file.
using (FileStream fs = fi.Create())
{
Byte[] info =
new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
fs.Close();
}
}
// Open the stream and read it back.
using (StreamReader sr = fi.OpenText())
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Process .....
}
}
}
}
Version Information
.NET
Supported in: 6.0
.NET Compact Framework
Supported in: 3.5
See Also