//author: walker
//date: 2014-01-07
//function: 将DataTable导出到csv文件
public static bool datatableToCSV(DataTable dt, string pathFile)
{
string strLine = "";
StreamWriter sw;
try
{
sw = new StreamWriter(pathFile, false, System.Text.Encoding.GetEncoding(-0)); //覆盖
//表头
for (int i = 0; i < dt.Columns.Count; i++)
{
if (i > 0)
strLine += ",";
strLine += dt.Columns[i].ColumnName;
}
strLine.Remove(strLine.Length - 1);
sw.WriteLine(strLine);
strLine = "";
//表的内容
for (int j = 0; j < dt.Rows.Count; j++)
{
strLine = "";
int colCount = dt.Columns.Count;
for (int k = 0; k < colCount; k++)
{<