StreamWriter sw = new StreamWriter(filePath, false); int iColCount = dataTable.Columns.Count; //for (int i = 0; i < iColCount; i++) //{ // sw.Write(dataTable.Columns[i]); // if (i < iColCount - 1) // { // sw.Write("|"); // } //} //sw.Write(sw.NewLine); foreach (DataRow row in dataTable.Rows) { for (int i = 0; i < iColCount; i++) { if (!Convert.IsDBNull(row[i])) { sw.Write(row[i].ToString()); } if (i < iColCount - 1) { sw.Write("|"); } } sw.Write(sw.NewLine); } sw.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)