csvhelper - C# CSVWriter how to avoid getting empty line at the end of writing all lines to a file -
i using csvwriter write csv using following link:
how create csv header , footer using linqtocsv or better in c#
but reason getting empty line created @ end. can me doing wrong or how can avoid getting empty line?
here code create csv using csvwriter:
        using (var writer = file.appendtext(outputcsv))         {             var csv = new csvwriter(writer);             csv.configuration.registerclassmap<custommap>();             csv.configuration.hasheaderrecord = true;             csv.configuration.quotenofields = true;             csv.configuration.delimiter = "|";              csv.writerecords(asrunlogs.tolist());             csv.writerecord(new csvfooterrecord()             {                 footertext =                     $"trailer:{"qsaam_promos.csv"}|{datetime.now.tostring("ddmmyyhhmm")}|{asrunlogs.count}"             });         } when open file in notepad++, can see empty line @ end.
appreciate regard this.
thanks
you do
writer.write($"trailer:{"qsaam_promos.csv"}|{datetime.now.tostring("ddmmyyhhmm")}|{asrunlogs.count}"); writer.flush(); instead of
csv.writerecord(new csvfooterrecord() {     footertext =         $"trailer:{"qsaam_promos.csv"}|{datetime.now.tostring("ddmmyyhhmm")}|{asrunlogs.count}" }); 
Comments
Post a Comment