title: FileHelpers: CsvEngine.DataTableToCsv creates invalid CSV
body: <p>I'm using FileHelpers to export dynamically created data from my application. I have a DataGridView whose columns and rows can be edited by the users (add, delete, manipulated), so I have no idea what data is finally passed to FileHelpers.</p>
  
  <p>Reading <a href="https://stackoverflow.com/questions/2112924/dynamically-create-a-csv-file-with-filehelpers/2112993#2112993">Dynamically create a CSV file with FileHelpers</a> pointed me to the <a href="http://www.filehelpers.com/FileHelpers.CsvEngine.DataTableToCsv_overloads.html" rel="nofollow noreferrer">CsvEngine.DataTableToCsv</a> method. Unfortunatly, this method does neither escape fields containing the delimiter nor doublequotes nor newlines.</p>
  
  <p>If I had a predefined class, I could use the FieldQuoted-Annotation to make FileHelper use a proper format, but since that is not the case, I do not know how to archive this with dynamically created data.</p>
  
  <p><strong>//Edit: Some code / Current approach:</strong></p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Converts the Data in a DGV into a DataTable.
      /// &lt;/summary&gt;
      /// &lt;param name="dataGridView"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public static DataTable GetDataTableFromDGV(DataGridView dgv)
      {
          DataTable myDT = new DataTable();
          // add Columns
          foreach (DataGridViewColumn col in dgv.Columns)
          {
              myDT.Columns.Add(col.Name);
          };
  
          // add Rows
          foreach (DataGridViewRow row in dgv.Rows)
          {
              List&lt;Object&gt; line = new List&lt;object&gt;();
              foreach (DataGridViewCell cell in row.Cells)
              {
                  line.Add(cell.Value);
              }
              myDT.Rows.Add(line.ToArray&lt;Object&gt;());
          }
          return myDT;
      }
  
      public void main(){
  
          String filename = "test.csv"
          DataTable dt = GetDataTableFromDGV(this.dgv);
          CsvEngine.DataTableToCsv(dt, filename, ',');
  
      }
  </code></pre>
  
  <p>Any Ideas?</p>