473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Odd HtmlInputFile experience - not streaming data

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.

Expand|Select|Wrap|Line Numbers
  1. HttpPostedFile MyFile;
  2. int FileLen;
  3. System.IO.Stream MyStream;
  4. MyFile = inputFileControl.PostedFile;
  5. FileLen = MyFile.ContentLength;
  6. byte[] input = new byte[FileLen];
  7.  
  8. // Initialize the stream.
  9. MyStream = MyFile.InputStream;
  10.  
  11. // Read the file into the byte array.
  12. MyStream.Read(input, 0, FileLen);
  13.  
But if I do it this way:

Expand|Select|Wrap|Line Numbers
  1. HttpPostedFile MyFile;
  2. int FileLen;
  3. System.IO.Stream MyStream;
  4.  
  5. MyFile = inputFileControl.PostedFile;
  6. FileLen = MyFile.ContentLength;
  7. byte[] input = new byte[FileLen];
  8.  
  9. MyFile.SaveAs("c:\\tempName.jpg");
  10.  
  11. // Initialize the stream.
  12. MyStream = new Stream("c:\\tempName.jpg",  FileAccess.Read);
  13.  
  14. // Read the file into the byte array.
  15. MyStream.Read(input, 0, FileLen);
  16.  
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.
Nov 19 '05 #1
1 1365
Looks like if I set position to 0 before I do the read it works just fine.
"Joel Barsotti" <jo***@stocklayouts.com> wrote in message
news:Oc**************@TK2MSFTNGP15.phx.gbl...
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.

Expand|Select|Wrap|Line Numbers
  1.  HttpPostedFile MyFile;
  2.  int FileLen;
  3.  System.IO.Stream MyStream;
  4.  MyFile = inputFileControl.PostedFile;
  5.  FileLen = MyFile.ContentLength;
  6.  byte[] input = new byte[FileLen];
  7.  // Initialize the stream.
  8.  MyStream = MyFile.InputStream;
  9.  // Read the file into the byte array.
  10.  MyStream.Read(input, 0, FileLen);
  11.  

But if I do it this way:

Expand|Select|Wrap|Line Numbers
  1.  HttpPostedFile MyFile;
  2.  int FileLen;
  3.  System.IO.Stream MyStream;
  4.  MyFile = inputFileControl.PostedFile;
  5.  FileLen = MyFile.ContentLength;
  6.  byte[] input = new byte[FileLen];
  7.  MyFile.SaveAs("c:\\tempName.jpg");
  8.  // Initialize the stream.
  9.  MyStream = new Stream("c:\\tempName.jpg",  FileAccess.Read);
  10.  // Read the file into the byte array.
  11.  MyStream.Read(input, 0, FileLen);
  12.  

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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim Chandler | last post by:
Hi all, I'm developing an application for a company to allow their clients to transfer large volumes of data to our production servers. I looked at using the HtmlInputFile control to handle...
4
by: R Reyes | last post by:
I am coding a forum and am having problems passing around the attachment file (as an HtmlInputFile) from page to page. Sometimes the users may want to preview their posts with the attachment specs...
1
by: Newbie | last post by:
i have a c# asp.net webform that has an HtmlInputFile and a listbox (to hold the filenames to be uploaded). but HtmlInputFile.PostedFile and HtmlInputFile.Value are readonly properties. i have to...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
5
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert...
2
by: Augusto Cesar via DotNetMonster.com | last post by:
Hi, I want to customize the HtmlInputFile. I wanna something like an image button to play the "browse" button hole and hide the textbox. Is that possible? I also have tried to hide an...
7
by: Buddy Ackerman | last post by:
I created this class Public Class HTMLFileInput : Inherits System.Web.UI.HtmlControls.HtmlInputFile Public Property Data As String Get Return ViewState("HTMLFileInput.Data") End Get Set...
0
by: ian | last post by:
Hello, I have a small test.aspx page with an HtmlInputFile class instance and an imagebutton. When I run this on our proxy server and click the save imagebutton I get the "Page cannot be...
5
by: pmakoi | last post by:
dear all this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.