Download Program: Resume Download Ability

lickuid

Active member
Joined
Nov 6, 2006
Messages
37
Programming Experience
Beginner
I suppose this is really a theoretical question above all else. I haven't really started on this project yet as I'm still in the planning stage. I'm not sure but I think it's the system.net.webclient object that does file downloads. However, I'm wondering if there's a way (a method of sorts) to do resumable file downloads, in case the connection is interrupted in any way. As always, thanks you all.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
The WebClient is simplified, to make advanced features you have to work with the WebRequest. There is a difference with web downloads from the protocols FTP (file server) and HTTP (web server). Not all servers support resumes (both protocols).

For FTP you send REST command first, then continue with RETR.
For HTTP the key header is "Accept-Ranges". See for example HTTP Partial Get
 

lickuid

Active member
Joined
Nov 6, 2006
Messages
37
Programming Experience
Beginner
so JohnH, you're saying to send headers to the server when downloading the file. keeping track of how much has been downloaded already? Of that example you sent me, what exactly tells the server how much has already been downloaded?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
Nothing in that example indicated how much has been downloaded, that is irrelevant for the request itself, the request only concerns what you want. It is the Range header set through the request.AddRange method that specifies bytes from-index and to-index. If you have a broken/partial download you first check how many bytes that local file is, this is the from-index for the next request. The initial request also exposed the full bytes length with the response.ContentLength property.
 
Top Bottom