Solved

simple download q

Posted on 2001-08-08
10
170 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 36
C++ dll will not run on machine without VS installed 10 87
is twain_32.dll cmpatible with windows 10 ? 10 184
C++ Code Issue 4 25
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

861 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