c# filestream read text code example
Example 1: c# read all lines from filestream
public IEnumerable<string> ReadLines(Func<Stream> streamProvider,
Encoding encoding)
{
using (var stream = streamProvider())
using (var reader = new StreamReader(stream, encoding))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
Example 2: how to read a text file C#
string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");