Writetimeout ='fs.writetimeout'抛出了'system.invalidoperationexception'类型的异常 [英] Writetimeout = 'fs.writetimeout' threw an exception of type 'system.invalidoperationexception'

查看:294
本文介绍了Writetimeout ='fs.writetimeout'抛出了'system.invalidoperationexception'类型的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friend,

目前我在从

Hello Friend,
Currently i am facing a problem while reading filestream byte from

postedFile




foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
            {
Stream fs = postedFile.InputStream;
                    BinaryReader br = new BinaryReader(fs);
                    Byte[] bytes = br.ReadBytes((Int32)fs.Length);



}

异常来自


}
Exception coming as

ReadTimeout = 'fs.ReadTimeout' threw an exception of type 'System.InvalidOperationException'





任何人都可以帮助我,如果我错过了页面级别的内容或其他内容吗?



我尝试了什么:





Can anyone help me if i missing something in page level vlidation or else?

What I have tried:

Stream fs = postedFile.InputStream;
                    BinaryReader br = new BinaryReader(fs);
                    Byte[] bytes = br.ReadBytes((Int32)fs.Length);

推荐答案

使用 HttpPostedFile.ContentLength Property(System.Web) [ ^ ]而不是 Stream.Length

Use the HttpPostedFile.ContentLength Property (System.Web)[^] instead of Stream.Length:
Byte[] bytes = br.ReadBytes(postedFile.ContentLength);





或如图所示 HttpPostedFile.InputStream属性(System.Web)中的示例 [ ^ ]:



Or as shown in the example at HttpPostedFile.InputStream Property (System.Web)[^]:

byte[] bytes = new byte[postedFile.ContentLength];
fs.Read(bytes, 0, postedFile.ContentLength);

[/ EDIT]


这篇关于Writetimeout ='fs.writetimeout'抛出了'system.invalidoperationexception'类型的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆