Odd HtmlInputFile experience - not streaming data

J

Joel Barsotti

Hi I'm trying to gather data out of a HtmlInputFile control. After this
section of code when looking in the debugger, input is still empty.

Code:
HttpPostedFile MyFile;
int FileLen;
System.IO.Stream MyStream;
MyFile = inputFileControl.PostedFile;
FileLen = MyFile.ContentLength;
byte[] input = new byte[FileLen];

// Initialize the stream.
MyStream = MyFile.InputStream;

// Read the file into the byte array.
MyStream.Read(input, 0, FileLen);

But if I do it this way:

Code:
HttpPostedFile MyFile;
int FileLen;
System.IO.Stream MyStream;

MyFile = inputFileControl.PostedFile;
FileLen = MyFile.ContentLength;
byte[] input = new byte[FileLen];

MyFile.SaveAs("c:\\tempName.jpg");

// Initialize the stream.
MyStream = new Stream("c:\\tempName.jpg",  FileAccess.Read);

// Read the file into the byte array.
MyStream.Read(input, 0, FileLen);

This results in the input string having content in the input stream.

Either way when I look at the debugger the MyStream object is filled with
content, but one way the read doesn't seem to work, the other way it does.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top