Solved

simple download q

Posted on 2001-08-08
10
166 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
Comment Utility
Is this a non-MFC application?

What is the OS and the compiler?
0
 
LVL 10

Author Comment

by:makerp
Comment Utility
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
Comment Utility
>>(i can do that too already).

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

Expert Comment

by:Axter
Comment Utility
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
Comment Utility
thank you Axter,

just a link to example would do
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 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

9 Experts available now in Live!

Get 1:1 Help Now