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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top