我正在使用Filehelpers库并使用WriteStream方法输出我的csv。它工作正常,除了文件在数据中间切断,打开文件时它只有前2048个字符。如何让它输出整个数据集?
// 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();
答案 0 :(得分:0)
我明白了。
我将Streamwriter的Autoflush属性设置为true并删除了“Response.Flush”行,它现在输出了全部数据。