I want to read big TXT file size is 500 MB, First I use
var file = new StreamReader(_filePath).ReadToEnd(); var lines = file.Split(new[] { \'\\n\' }); >
Just use File.ReadLines which returns an IEnumerable and doesn't load all the lines at once to the memory.
IEnumerable
foreach (var line in File.ReadLines(_filePath)) { //Don't put "line" into a list or collection. //Just make your processing on it. }