One way to go in a file and read the lines in C# is to use FileStream and StreamReader together, you should always use while loop instead of for loop, otherwise, you will get the error I keep getting for this is: Cannot convert type ‘char’ to ‘string’.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace testing
{
public class Program
{
public static void Main(string[] args)
{
string file = @"C:TempNew FolderNew Text Document.txt";
using(FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
using(StreamReader sr = new StreamReader(fs))
{
while(!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
}
}
}
}
}
}