【发布时间】:2013-12-26 09:47:13
【问题描述】:
我有一个 asp.net FileUpload 控件。 我可以成功上传文件以存储在会话中,但是当我试图获取它的输入流时 (我将文件存储在 HttpPosterFile 中)我收到错误
无法访问已关闭的文件
tr.PostedFile //<== HttpPostedFile;
byte[] byteArray = null;
using (var binaryReader = new BinaryReader(tr.PostedFile.InputStream))
{
byteArray = binaryReader.ReadBytes(tr.PostedFile.ContentLength);
}
【问题讨论】:
-
将文件数据的字节数组存储在会话中而不是使用流中的 HttpPostedFile 不是更好吗?
标签: c# asp.net file-upload httppostedfile