I am using the Filehelpers library and outputting my csv using the WriteStream method. It is working fine except the file is cutting off in the middle of the data and upon opening the file it only has the first 2048 characters. How do I get it to output the entire dataset?
// gisList is a list of objects whose class is set to be a [DelimitedRecord(",")]
var gisEngine = new FileHelperEngine<GisRecord>();
var gisstream = new MemoryStream();
var gisstreamWriter = new StreamWriter(gisstream);
gisEngine.WriteStream(gisstreamWriter, gisList);
gisstream.Position = 0;
Response.ContentType = @"application/x-msdownload";
Response.AppendHeader("content-disposition", "attachment; filename=gisOutput.txt");
var reader = new StreamReader(gisstream);
Response.Write(reader.ReadToEnd());
Response.Flush();
Response.End();
I figured it out.
I set the Streamwriter's Autoflush property to true and removed the "Response.Flush" line and it outputs the whole amount of data now.