Export data using FileHelpers

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

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

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

+3
source share
1 answer

Perhaps you could use this:

CommonEngine.DataTableToCsv(dt, "customers.csv", '|');
+5
source

Source: https://habr.com/ru/post/1705046/


All Articles