470,596 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Downloading files in pieces with WebRequest/WebResponse

From what I am reading, a System.Net.WebRequest can be set to retrieve just
parts of a file in the WebResponse, using the .AddRange method to specify a
byte range. This would be very useful for me for a client that I want to
build which will download files in a small footprint.

However, what I'm missing (probably just overlooking) is how to use the
WebRequest or WebResponse to query a file's size, so that you know what your
maximum range is - how can you get the number of bytes for a potential
download before actually beginning?

Richard
Mar 24 '06 #1
1 2359
> However, what I'm missing (probably just overlooking) is how to use the
WebRequest or WebResponse to query a file's size, so that you know what
your maximum range is - how can you get the number of bytes for a
potential download before actually beginning?
AFAIK there is no simple way to knowing it. Some web servers will specify
content-length, and some will not. they can even put content-length to -1.

So, what the client has to do in this case?

In your situation, I'd specified some fixed range which can be adjusted by
some heuristics, if content length is not specified.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

"Richard K Bethell" <so*****@spammingisevil.bad> wrote in message
news:%2******************@tk2msftngp13.phx.gbl... From what I am reading, a System.Net.WebRequest can be set to retrieve
just parts of a file in the WebResponse, using the .AddRange method to
specify a byte range. This would be very useful for me for a client that I
want to build which will download files in a small footprint.

Mar 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rajiv Barik | last post: by
reply views Thread by Amol Guttal via .NET 247 | last post: by
8 posts views Thread by John K. | last post: by
12 posts views Thread by ThyRock | last post: by
reply views Thread by Gordon | last post: by
4 posts views Thread by Richard L Rosenheim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.