문제

I have a asp.net FileUpload control. I can successfully upload file to store in session, but when I am tring to get its inputstream (I'm store file in HttpPosterFile) I'm getting error

Cannot access a closed file

tr.PostedFile //<== HttpPostedFile; 
byte[] byteArray = null; 
using (var binaryReader = new BinaryReader(tr.PostedFile.InputStream)) 
{ 
    byteArray = binaryReader.ReadBytes(tr.PostedFile.ContentLength); 
}
도움이 되었습니까?

해결책

add this to your web.config file

<system.web>
  <httpRuntime useFullyQualifiedRedirectUrl="true" maxRequestLength="15360" requestLengthDiskThreshold="15360"/>
</system.web>

http://sanjaysainitech.blogspot.com/2008/12/file-upload-error-can-not-access-closed.html

다른 팁

Did you use using?

If yes pay attention to not close this before you put the string to the inputstream.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top