Dragging DataGridView, Button from your Visual Studio toolbox into your form designer, then design a simple windows forms allows you to export datatable to csv file using CsvHelper in c# as shown below.

Right-clicking on your project, then select Manage Nuget Packages from the Visual Studio.
Next, Search 'CsvHelper', then download and install it.

CsvHelper is an open source library helps you read and write csv files. It's extremely fast, flexible, and easy to use. Supports reading and writing of custom class objects.
Adding a bindingsource to the DataGridView allows you to binding customer data from the Northwind database.
private void frmExportDataTableToCsvUsingCsvHelper_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'appData.Customers' table. You can move, or remove it, as needed.
this.customersTableAdapter.Fill(this.appData.Customers);
}
Adding a click event handler to the Export button allows you to export datatable to csv file using CsvHelper in c#.
private void btnExportData_Click(object sender, EventArgs e)
{
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "CSV files|*.csv" })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
using (var textWriter = File.CreateText(sfd.FileName))
{
using (CsvWriter csv = new CsvWriter(textWriter, System.Globalization.CultureInfo.CurrentCulture))
{
DataTable dt = this.appData.Customers.CopyToDataTable();
// Write columns
foreach (DataColumn column in dt.Columns)
csv.WriteField(column.ColumnName);
csv.NextRecord();
// Write row values
foreach (DataRow row in dt.Rows)
{
for (var i = 0; i < dt.Columns.Count; i++)
csv.WriteField(row[i]);
csv.NextRecord();
}
}
}
MessageBox.Show("You have successfully exported the file.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Using CreateText of File class to create your file, then use the CsvWriter class to write data from your DataTable to csv file using WriteField method, the NextRecord method allows you to append new line.
Through this c # example, I showed you a simple way to export data from DataTable to CSV file using CsvHelper in c # windows forms application.