Write Rows from DataTable to Text File

前端 未结 6 1580
面向向阳花
面向向阳花 2021-02-14 11:31
public void GenerateDetailFile()
{
  if (!Directory.Exists(AppVars.IntegrationFilesLocation))
  {
    Directory.CreateDirectory(AppVars.IntegrationFilesLocation);
  }

          


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 12:20

    When you try to print out a DataRow like that, it is calling Object.ToString(), which simply prints out the name of the type. What you want to do is something like:

    sw.WriteLine(String.Join(",", row.ItemArray));
    

    This will print a comma separated list of all of the items in the DataRow.

提交回复
热议问题