Filehelpers WriteStream 只写前 2048 个字符输出

Filehelpers WriteStream only writing the first 2048 characters to output

我正在使用 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();

我明白了。

我将 Streamwriter 的 Autoflush 属性 设置为 true 并删除了 "Response.Flush" 行,它现在输出全部数据。