Loop on all lines of very large file C# : <p>I want to loop on all the lines of a very large file (10GB for example) using <code>foreach</code></p>

<p>I am currently using <code>File.ReadLines</code> like that:</p>

<pre><code>var lines = File.ReadLines(fileName);
foreach (var line in lines) {
  // Process line
}
</code></pre>

<p>But this is very slow if the file is larger than 2MB and it will do the loop very slowly.</p>

<p>How can I loop on very large files?</p>

<p>Any help would be appreciated.</p>

<p>Thanks!</p>
