title: Exporting DataGridView to a CSV text file
body: <p>I wrote the following code, but it does not work (It saves stupid things in my CSV file). What can be wrong? There are two columns in my DataGridView.</p>
  
  <pre><code>var strValue = new StringBuilder();
  
  foreach(DataGridViewRow row in dataGridView1.Rows)
  {
      strValue.AppendLine(row.Cells[0] + "," + row.Cells[1]);
  }
  
  string strFile = Properties.Settings.Default.AutoCompleteFile; //File Path
  
  if (!string.IsNullOrEmpty(strValue.ToString()))
  {
      File.WriteAllText(strFile, strValue.ToString(), Encoding.UTF8);
  }
  </code></pre>
  
  <p>This is the result I get in the saved file:</p>
  
  <blockquote>
    <p>ï»¿DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=0 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=0 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=1 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=1 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=2 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=2 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=3 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=3 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=4 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=4 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=5 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=5 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=6 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=6 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=7 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=7 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=8 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=8 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=9 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=9 }
    DataGridViewTextBoxCell { ColumnIndex=0, RowIndex=10 },DataGridViewTextBoxCell { ColumnIndex=1, RowIndex=10 }</p>
  </blockquote>