Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic static Boolean EcrireDansUnfichier(DataTable dt, string filePath) { int i = 0; StreamWriter sw = null; try { sw = new StreamWriter(filePath, false); for (i = 0; i <= dt.Columns.Count - 1; i++) { sw.Write(dt.Columns[i].ColumnName + "|"); } sw.WriteLine(); foreach (DataRow Rows in dt.Rows) { Object[] array = Rows.ItemArray; for (i = 0; i < array.Length - 1; i++) { sw.Write(array[i].ToString() + "|"); } sw.WriteLine(); } sw.Close(); return true; } catch (Exception ex) { MessageBox.Show("Une opération incorrecte: \n" + ex.ToString(), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }