public string ExportBim360Projects() { string retu = new string(""); MemoryStream stream = new MemoryStream(); using (var streamWriter = new StreamWriter(stream)) { //maybe the CultureInfo needs to be changed //change that everything should get written //CsvConfiguration test = new CsvConfiguration() using (var csv = new CsvWriter(streamWriter, CultureInfo.InvariantCulture)) { //Maps the Header of the CSV Data to the class attributes var tmp = SerializationParser.ExportBim360ToCSV(projects); if (tmp == null) { return(retu); } //this is really dirty but it works for now for (int i = 0; i < 50; i++) { tmp.Add(new UserData()); } csv.Context.RegisterClassMap <UserDataExport>(); //csv.WriteHeader<UserData>(); csv.WriteRecords(tmp); // convert stream to string stream.Position = 0; StreamReader reader = new StreamReader(stream); retu = reader.ReadToEnd().ToString(); } } return(retu); }
public void ExportBim360Projects(string filepath) { using (var streamWriter = new StreamWriter(filepath)) { //maybe the CultureInfo needs to be changed using (var csv = new CsvWriter(streamWriter, CultureInfo.InvariantCulture)) { //Maps the Header of the CSV Data to the class attributes var tmp = SerializationParser.ExportBim360ToCSV(projects); csv.Context.RegisterClassMap <UserDataExport>(); if (tmp != null) { csv.WriteRecords(tmp); } } } }