title: Faster way of reading csv to grid
body: <p>I have following in Windows Forms .NET 3.5</p>
  
  <p>It works fine for csv with records less than 10,000 but is slower for records above 30,000.
  Input csv  file can can any records between 1 - 1,00,000 records </p>
  
  <p>Code currently used :</p>
  
  <pre><code>/// &lt;summary&gt;
          /// This will import file to the collection object
          /// &lt;/summary&gt;
          private bool ImportFile()
          {
              try
              {
  
                  String fName;
                  String textLine = string.Empty;
                  String[] splitLine;
  
                  // clear the grid view
  
                  accountsDataGridView.Rows.Clear();
  
                  fName = openFileDialog1.FileName;
  
                  if (System.IO.File.Exists(fName))
                  {
                      System.IO.StreamReader objReader = new System.IO.StreamReader(fName);
  
                      do
                      {
                          textLine = objReader.ReadLine();
                          if (textLine != "")
                          {
                              splitLine = textLine.Split(',');
                              if (splitLine[0] != "" || splitLine[1] != "")
                              {
                                  accountsDataGridView.Rows.Add(splitLine);
                              }
                          }
                      } while (objReader.Peek() != -1);
                  }
                  return true;
              }
              catch (Exception ex)
              {
                  if (ex.Message.Contains("The process cannot access the file"))
                  {
                      MessageBox.Show("The file you are importing is open.", "Import Account", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  }
                  else
                  {
                      MessageBox.Show(ex.Message);
                  }
  
                  return false;
              }
  
          }
  </code></pre>
  
  <p>Sample Input file :
   <br />
  18906,Y<br />
  18908,Y<br />
  18909,Y<br />
  18910,Y<br />
  18912,N<br />
  18913,N<br /></p>
  
  <p>Need some advice on optimizing this code for fast reads &amp; view in grid.</p>