C# File.ReadLines() .net 4.0
In C#.net you can open large file in chunks to read lines one by one or line by line. Here is an example of Read File Lines in Vb.net and C#.net. In .net Framework 4.0, File instance has new static method called ReadLines. Let's see program in C# and Vb.net to read large size files. You may want to process very large file line by line. This method is very useful as it returns line only when needed and saves the resources.
File.ReadLines provides IEnumerator before loading the entire collection of file in memory. It's very useful method when file is very big in size to load in memory. You can write memory efficient code which will save limited resources.
static void Main(string args)
foreach (string line in File.ReadLines(@"C:\xxx\Large_File_example.txt"))
if (line.Contains("code") & line.Contains("Satalaj"))
VB.net program to read large file line by line.
Private Shared Sub Main(args As String())
For Each line As String In File.ReadLines("C:\xxx\Large_File_example.txt")
If line.Contains("code") And line.Contains("Satalaj") Then