Solved

simple download q

Posted on 2001-08-08
10
169 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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
 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

778 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