c# - CSVHelper - No Output -


i trying create csv file using csvhelper nuget package

this code

public actionresult test() {     var ms = new memorystream();     var sr = new streamwriter(ms);     var csv = new csvwriter(sr);      csv.writefield("sd");     csv.writefield("sd");     csv.writefield("sd");     csv.writefield("sd");      //ms.seek(0, 0);     sr.flush();     //ms.position = 0;     var len = ms.length;      return file(ms, "text/csv", "test.csv"); } 

however, file blank

i have read several questions on here suggest streamwriter needs flushed. position moved 0. however, ive tried , doesnt seem work

i have tried same using statements memorystream, streamwriter , csvwriter i've tried of these , still blank

whatsmore, length of memorystream 0

what doing wrong?

figured out - needed pass byte array, instead of stream, filecontentresult :

return file(ms.toarray(), "text/csv", "test.csv"); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -