title: Read text file with lots of line in C#
body: <p>I have a text file, that could potentially have up to 1 Million lines in it, and I have a code for reading the file one line at a time, but this is taking a lot of time...lots and lots of time. Is there a method in c# to potentially optimize this process, and improve the reading. This is the code I'm using.</p>
  
  <pre><code>using(var file = new StreamReader(filePath))
  {
      while((line = file.ReadLine()) != null)
       {
           //do something.
       }
  }
  </code></pre>
  
  <p>Any suggestions on reading these lines in bulk or improving the process?</p>
  
  <p>Thanks.</p>
  
  <p>Thanks for all your comments. The issue had to do with the \do something where I was using the SmartXls library to write to Excel, which was causing the bottle neck. I have contacted the developers to address the issue. All the suggested solutions will work in other scenarios. </p>