title: File.ReadAllLines or Stream Reader
body: <p>We can read file either by using <a href="http://msdn.microsoft.com/en-us/library/vstudio/system.io.streamreader" rel="noreferrer"><code>StreamReader</code></a> or by using <a href="http://msdn.microsoft.com/en-us/library/s2tte0y1.aspx" rel="noreferrer"><code>File.ReadAllLines</code></a>. </p>
  
  <p>For example I want to load each line into a <code>List</code> or <code>string[]</code> for further manipulation on each line.</p>
  
  <pre><code>string[] lines = File.ReadAllLines(@"C:\\file.txt");
  
  foreach(string line in lines)
  {
       //DoSomething(line);
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>using (StreamReader reader = new StreamReader("file.txt"))
  {
      string line;
  
      while ((line = reader.ReadLine()) != null)
      {
         //DoSomething(line); or //save line into List&lt;string&gt;
      }
  }
  
  //if list is created loop through list here 
  </code></pre>
  
  <p>Application come across different size of text file. Which could grow from few <code>KBs</code> to <code>MBs</code> occasionally.</p>
  
  <p>My question is that which one is preferred way and why one should be preferred over other?</p>