473,394 Members | 1,642 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,394 software developers and data experts.

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 2452
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rajiv Barik | last post by:
hi , I am trying to download a zip file from a http site using webResponse . here's the code WebRequest wReq ; wReq = WebRequest.Create(wUri ) ; wReq.Credentials = new NetworkCredential...
0
by: Amol Guttal via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Amol Guttal Hi, This is the code which used to download a file from webserver. If I point a file in my localhost for download...
8
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the...
12
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts...
0
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't...
4
by: Richard L Rosenheim | last post by:
I know that I can download a file from a web server by using the WebClient.DownloadFile method. But, does anyone know of an example of downloading a file from a web server with the ability to...
1
by: Hexman | last post by:
Code below ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a...
1
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie...
3
by: Gina_Marano | last post by:
Hey All, I need to download 1 or more files from a secure or unsecure website folder using HTTP. Here is what I have so far: public void GetHTTPImages() { WebClient HTTPClient = new...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.