using (var file = new StreamReader(fileName)) {
string line;
while((line = file.ReadLine()) != null)
{
System.Console.WriteLine(line);
}
}
Console.ReadLine();
//will read what was input to the command
using System;
using System.IO;
public class Example
{
public static void Main()
{
string fileName = @"C:examplepath.txt";
using (StreamReader streamReader = File.OpenText(fileName))
{
string text = streamReader.ReadToEnd();
string[] lines = text.Split(Environment.NewLine);
foreach (string line in lines) {
Console.WriteLine(line);
}
}
}
}
string GetLine(string fileName, int line)
{
using (var sr = new StreamReader(fileName)) {
for (int i = 1; i < line; i++)
sr.ReadLine();
return sr.ReadLine();
}
}