get a remote file via http

A

Andrea Moro

I need to get a remote file via http protocol, get it in some variable and
use with some unzipping tool to get the content.

So the problem I've is two. First how to read a remote file. I found that I
can access to a file with the WebRequest class, and it get, but I don't
know if the result is just the data collected in the property, or a sort of
stream ready to be used. There is the GetResponseStream that should do
this, but just after encapsulate the returned stream in a stream variable I
don't know how proceed.

Some links that can help me understand the streaming or better this kind of
logic I want to implement?

After all ... suppose to have the stream ... how to unzip it? I looked for
some free as well commercial component that is able to unzip a memory
stream. It doesn't seem to exist one. May be the exceed component, but I'm
not sure the stream they referer to is what I want.

Any helps also in this case?

Thanks in advance.

Andrea
 
P

Peter Rilling

A stream is just a stream whether it is a FileStream or a NetworkStream.
You just need to extract the bytes from the stream. Here is an article that
shows how to download a file?
(http://www.c-sharpcorner.com/internet/simplewebfiledownload.asp)

There is an opensource library called SharpZipLib that processes zip file.
I do not know if it can unzip from a stream since I have never used it, but
if nothing else, you can always save to a temp file, then process the file
with the library.
 
J

Joerg Jooss

Andrea said:
I need to get a remote file via http protocol, get it in some
variable and use with some unzipping tool to get the content.

So the problem I've is two. First how to read a remote file. I found
that I can access to a file with the WebRequest class, and it get,
but I don't know if the result is just the data collected in the
property, or a sort of stream ready to be used. There is the
GetResponseStream that should do this, but just after encapsulate the
returned stream in a stream variable I don't know how proceed.

Some links that can help me understand the streaming or better this
kind of logic I want to implement?

In addition to Peter's post, note that there's also
WebClient.DownloadFile() and .DownloadData(), which are simpler to use
than WebRequest.

Cheers,
 

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

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,038
Members
47,633
Latest member
BriannaLyk

Latest Threads

Top