Question: how to export data from dataset to csv file in c#?
Answer: public static void ToCSV(this DataTable dtDataTable, string strFilePath)
{
StreamWriter sw = new StreamWriter(strFilePath, false);
//headers.
for (int i = 0; i < dtDataTable. Columns. Count; i++)
{
sw. Write(dtDataTable. Columns[i]);
if (i < dtDataTable. Columns.