c#把DataTable的数据存到Text文件
public static void WriteTextFile(DataTable dt, string TextFile)
{
StringBuilder sbText = new StringBuilder();
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i
{
if (dr[i] != DBNull.Value)
sbText.Append(dr[i].ToString());
if (i
sbText.Append(splitStr);
}
sbText.Append("\r\n");
}
System.IO.StreamWriter sw = new System.IO.StreamWriter(TextFile, false, System.Text.Encoding.Default);
sw.Write(sbText.ToString());
sw.Close();
}