Solved

simple download q

Posted on 2001-08-08
10
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

752 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