我应该使用什么来将文件写入响应?在我看来,有两种不同的选择。选项一是将文件读入流中,然后将字节写入浏览器
Response.BinaryWrite(new bytes[5])
下一个选项是直接使用 Response.WriteFile 从文件系统写入文件。这两种方法有什么优点/缺点吗?
编辑:更正错别字
最佳答案
如果您在磁盘上有文件并且至少使用 asp.net 2.0,则首选 Response.TransmitFile。
Response.WriteFile 将整个文件读入内存,然后将文件写入响应。传输文件 "Writes the specified file directly to an HTTP response output stream without buffering it in memory."
关于asp.net - BinaryWrite 与 WriteFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/762471/