G
Guest
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
appreciated.
Thanks in advance
Ashish
try
{
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)
{
}
"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
appreciated.
Thanks in advance
Ashish
try
{
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)
{
}