Solved

simple download q

Posted on 2001-08-08
10
168 Views
Last Modified: 2007-12-19
Hi

i need the code to download a file via HTTP and save it to disk, also i need to know how to download from a given point in the file, for example 500k into it rather than from the begining

Paul
0
Comment
Question by:makerp
  • 6
  • 2
  • 2
10 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6365272
Is this a non-MFC application?

What is the OS and the compiler?
0
 
LVL 10

Author Comment

by:makerp
ID: 6365366
os Win, VC++ 5.0, i dont really need MFC cos i have my own socket classes etc that i will use. i am familiar with HTTP i just need to be shown how to make a request that will include the appropriate headers to get a portion of the file, for example 0 - 514 bytes or 514 - whatever. i want to write a tool that does downloads overnight, if the connection drops i want it to be able to dial a new connection then continue where it left off (i can do that too already).

i know that there are some tools for this already but in need to include this into my own tool, so i might aswell write my own

Paul
0
 
LVL 10

Author Comment

by:makerp
ID: 6365370
>>(i can do that too already).

this refers to the dialing of a connection BTW
0
 
LVL 30

Expert Comment

by:Axter
ID: 6365530
I'm familiar with the MFC method of doing this.  But the MFC method wouldn't help you because the CInternetConnection classes were not added to MFC until VC version 6.0.

So you're stock with the non-MFC method regardless.

If I can find my old non-MFC code to do this, I'll post it here.
0
 
LVL 10

Author Comment

by:makerp
ID: 6365597
thank you Axter,

just a link to example would do
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 49

Expert Comment

by:DanRollins
ID: 6367518
This link shows the open/read sequence using WinInet fns (I recommend against using any roll-your-own socket implementations).

http://msdn.microsoft.com/workshop/networking/wininet/overview/http.asp

Just throw in a call to the InternetSetFilePointer fn and there you go.
   
-- Dan
0
 
LVL 10

Author Comment

by:makerp
ID: 6429425
sorry to take ages over this, i have just got back from crete. Dan i will have a look at you link.
0
 
LVL 10

Author Comment

by:makerp
ID: 6429432
just to clarify, i could open four connections to the same file and use this method to have each connection start reading at a set amount into the file. also i could stop a download and then pick it up where i left off.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6431098
>>just to clarify, i could open four connections to the same file ...

That is not a clarification.  That is an expansion of the original question.

The answer is... it depends upon the server.  Not all servers accept an HTTP random access requests.  See:

http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/wininet/reference/functions/InternetSetFilePointer.asp

-- Dan
0
 
LVL 10

Author Comment

by:makerp
ID: 6479258
ok, i done what i want by using the range: header in a tcp/ip request.

anyway i did learn from your link dan

cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now