InvalidOperationException

InvalidOperationException

本文介绍了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);

推荐答案

Byte[] bytes = br.ReadBytes(postedFile.ContentLength);





或如图所示 []:



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'类型的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 10:44