将dataTable 保存到本地txt文件中
string path = ‘path’;
StringBuilder builder = new StringBuilder();
builder.AppendLine(errorTable.Columns[0].ColumnName + '/' + errorTable.Columns[1].ColumnName + '/' + errorTable.Columns[2].ColumnName + '/' + errorTable.Columns[3].ColumnName);
foreach (DataRow dr in errorTable.Rows)
{
builder.AppendLine(dr[0].ToString() + ',' + dr[1].ToString() + ',' + dr[2].ToString() + ',' + dr[3].ToString());
using (System.IO.FileStream file = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
using (System.IO.TextWriter text = new System.IO.StreamWriter(file, System.Text.Encoding.Default))
{
text.Write(builder.ToString());
}
}
}