asp.net - create csv file from multiple datatables in c# -


i want export data multiple datatables csv file.

i know how write 1 datatable csv.

any please. have function

 public void createcsvfile(datatable dt, string strfilepath)    {      try      {        streamwriter sw = new streamwriter(strfilepath, false);        int columncount = dt.columns.count;        (int = 0; < columncount ; i++)        {          sw.write(dt.columns[i]);          if (i < columncount - 1)          {            sw.write(",");          }        }        sw.write(sw.newline);        foreach (datarow dr in dt.rows)        {          (int = 0; < columncount ; i++)          {            if (!convert.isdbnull(dr[i]))            {              sw.write(dr[i].tostring());            }            if (i < columncount - 1)            {              sw.write(",");            }          }          sw.write(sw.newline);        }        sw.close();      }      catch (exception ex)      {        throw ex;      }    }   

you can append same file.

streamwriter constructor allowing append

other question regarding this


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -