csharp read file by line
Code Example - csharp read file by line
using (var file = new StreamReader(fileName)) {
string line;
while((line = file.ReadLine()) != null)
{
System.Console.WriteLine(line);
}
}
how to read particular line of file in csharp
string GetLine(string fileName, int line)
{
using (var sr = new StreamReader(fileName)) {
for (int i = 1; i < line; i++)
sr.ReadLine();
return sr.ReadLine();
}
}
csharp code to read txt file line by line and split
string lines = File.ReadAllText(path);
string [] split_arr = lines.Split(';')//files containt ; seprated values
foreach(string l in split_arr)
{
Console.WriteLine(l);
}