469,626 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

[System.ObjectDisposedException] = {"Cannot access a closed file."

I am using the following code and i am getting the following error :-
"Cannot access a closed file." while reading the content of the InputStream.
Microsoft suggestes that one should not release the stream before accessing
the same.But here i am not releasing the stream.Suggestions/pointers will be

Thanks in advance


foreach(HtmlInputFile hif in filesToImport)
// extract only the file name for the external file
string fileName = Path.GetFileName(hif.PostedFile.FileName);
// extract the content type (i.e. MIME type)
string mimeType = hif.PostedFile.ContentType;
// prepare to grab the content
byte[] content = new byte[hif.PostedFile.InputStream.Length];
// pull content out of the file
hif.PostedFile.InputStream.Read(content, 0, content.Length);
//Some more code...
catch(Exception exp)

May 10 '06 #1
0 5517

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Richard Blewett [DevelopMentor] | last post: by
8 posts views Thread by Michael | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.