Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HttpFileCollection and HttpPostedFile

8 views
Skip to first unread message

Jennifer Mathews

unread,
Nov 10, 2009, 2:55:19 PM11/10/09
to
I realize I can use

Dim hpf As HttpPostedFile
hpf.SaveAs("c:\whereever\filename.xxx) to save a file.

But I need to pass the hpf.InputStream to a class and save the file from there.
So all I do is need to pass a System.IO.Stream to it with hpf.InputStream .

Once that is passed, how do I know how to save contents of hpf.InputStream ?

Do I do a Binary Write or a regular Text Write?

Thanks


Gregory A. Beamer

unread,
Nov 11, 2009, 10:04:47 AM11/11/09
to
"Jennifer Mathews" <walters...@live.com> wrote in
news:FF6FB77C-2BDC-4BC2...@microsoft.com:


This depends on the content of what you are saving. If the file is an
image, a text write can end up saving the bytes as characters and not
bytes. Then you can read the file anytime you want, but not as a
picture. :-)

If you have the extension, you should be able to determine the file
type. If not, you can examine the stream and see if there is some
information about the file. Graphics files, for example, have headers
(find the first null char [ (char) 0 ] and the bits before it are the
header). You can read into a buffer until you hit the null char and then
read the header. If there is no header, I would assume a text file.

Peace and Grace,
Greg


--
Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************

Jennifer Mathews

unread,
Nov 13, 2009, 4:13:47 PM11/13/09
to
Thanks Greg. That got me going in the right direction.

"Gregory A. Beamer" <NoSpamM...@comcast.netNoSpamM> wrote in message
news:Xns9CC05C0E...@207.46.248.16...

0 new messages