I am exporting DataTable rows to csv file format should be like value, value2, value3 , and so on but my output file shows values like this "Value", "value2", "value3" Here is my sample code
Utilities.WriteDataTable(TempTable, writer, true);
public static void WriteDataTable(DataTable sourceTable, TextWriter writer, bool includeHeaders)
{
//Checking if Table has headers :
if (includeHeaders)
{
//Getting Headers:
List<string> headerValues = new List<string>();
foreach (DataColumn column in sourceTable.Columns)
{
headerValues.Add(QuoteValue(column.ColumnName));
}
writer.WriteLine(String.Join(",", headerValues.ToArray()));
}
//fetching rows from DataTable and Putting it in Array
string[] items = null;
foreach (DataRow row in sourceTable.Rows)
{
items = row.ItemArray.Select(o => QuoteValue(o.ToString())).ToArray();
writer.WriteLine(String.Join(",", items));
}
writer.Flush();
}