3

I want to export the contents of a DataTable to a text delimited file using FileHelpers, is this possible? Here is what I have so far:

// dt is a DataTable with Rows in it
DelimitedClassBuilder cb = new DelimitedClassBuilder("MyClassName", "|", dt);
Type t = cb.CreateRecordClass();
FileHelperEngine engine = new FileHelperEngine(t);

I have to convert the contents of dt to an array of type "MyClassName" but I'm not sure how to do that? I know there is a FileDataLink class but none of them work with DataTable (or even a DataSet).

Canavar
  • 47,715
  • 17
  • 91
  • 122
Nick Dat Le
  • 369
  • 4
  • 12

1 Answers1

6

Maybe you could use this:

CommonEngine.DataTableToCsv(dt, "customers.csv", '|');
Petros
  • 8,862
  • 3
  • 39
  • 38