Odd HtmlInputFile experience - not streaming data

  • Thread starter Thread starter Joel Barsotti
  • Start date Start date
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.
 
Back
Top