473,327 Members | 2,071 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,327 software developers and data experts.

Upload file and read contents from the stream?

I would like to provide an interface for users to upload a csv (or other
text file). I would like to read the contents of the CSV while it is
uploading (from the stream). Is this possible? It is no trouble to read it
once it is saved, but I was thinking I could possibly save a step.

Thanks,

Chris
Nov 17 '05 #1
2 8601

"Chris Holliday" <ch***@noSpamPlease-adventureology.com> wrote in message
news:#f*************@tk2msftngp13.phx.gbl...
I would like to provide an interface for users to upload a csv (or other
text file). I would like to read the contents of the CSV while it is
uploading (from the stream). Is this possible? It is no trouble to read it
once it is saved, but I was thinking I could possibly save a step.

For the archives:

This is easily handled by doing something like the following:

Dim str As Stream

str = MyFile.PostedFile.InputStream()

Dim myText As String

Dim sb As New System.Text.StringBuilder()

Dim sr As StreamReader = New StreamReader(str)

myText = sr.ReadLine()

In the above, MyFile is the file input from the webform.

Thanks,

C.

Nov 17 '05 #2
HttpPostedFile.InputStream

Gets a Stream object which points to an uploaded file to prepare for reading
the contents of the file.

Read directly from this, and you never have to call the SaveAs method first.
I was minding my own business when Chris Holliday blurted out:
I would like to provide an interface for users to upload a csv (or other
text file). I would like to read the contents of the CSV while it is
uploading (from the stream). Is this possible? It is no trouble to read it
once it is saved, but I was thinking I could possibly save a step.

Thanks,

Chris


--
Insert corny line here
Nov 18 '05 #3

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

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
1
by: David | last post by:
Hello. How can I load uploaded (from HtmlInputFile.PostedFile Property) file into Stream object without saving it to disk? Can anybody show me some simple? Thank you.
0
by: prasenjit2007 | last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:- <html> <body> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="50" ...
4
by: google.com | last post by:
Hi there! I've been digging around looking for a sample on how to upload a file without user action. I found the following article covering the area: ...
6
by: J055 | last post by:
Hi I have the following code. I upload an XML file using the FileUpload object, store the stream in a session so the user gets the chance to confirm some options then pass the stream from the...
2
by: hotflash | last post by:
Hi Master CroCrew, I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same...
2
by: webguy262 | last post by:
I'm trying to troubleshoot a membership script. The script is attempting to write to a file called .fdaccess. The function that's throwing the error is in a file called htpasswd.php. Here's the...
2
by: lka527 | last post by:
I am trying to make a site available for someone to *upload* certain type of text file (.txt) that can be parsed by written code. the upload file is available on the main site but I need this to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.