I have problems in my code when i want to populate my CSV with Date,Num, Piece,RefPiece,Montant,Libelle of each item in my listview. now my code generate csv file with all items'data and not each item's data in one csv file. here is my code if someone can edit it for me please :
ArrayList myList = new ArrayList(listView.Items); int counter = 0; foreach (var list in myList) { CsvContext cc = new CsvContext(); string myPath = @"C:\Users\DefaultAccount\Desktop\Projet Top Of Travel\FichiersCSV\"; string filename = string.Format("Facture{0}.csv", counter); string finalPath = System.IO.Path.Combine(myPath, filename); var lastItem = myList[myList.Count - 1]; var infoEcheances = from i in db.F_ECHEANCES select new { i.ECH_DateEch, i.CG_Num, i.ECH_Piece, i.ECH_RefPiece, i.ECH_Montant, i.ECH_Libelle }; if (myList != lastItem) { cc.Write(infoEcheances, finalPath, outpCsvFileDescription); counter++; } } //MessageBox.Show(DatePicker.SelectedDate.ToString()); listView.DataContext = query.ToList().Distinct();