Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0
How to read the file using the URL?Using URLDownloadToFile. Want to read the file and saving it in a variable instead of saving the file in hard disk?
Posted 23-May-11 19:57pm
Comments
S Mewara at 24-May-11 1:41am
   
Any effort?
Gokulnath007 at 24-May-11 1:57am
   
I have used URLDownloadToFile and downloaded the file to hard disk, but i just want to read the contents of the file instead of saving to the system.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In a overlapped operation:
 
Call WSASend[^] with lpBuffers point to the file you want to download, for example:
 
WSABUF sendBuf;
sendBuf.buf = "GET /index.html HTTP/1.1\r\n\r\n";
sendBuf.len = strlen( sendBuf.buf );
 
WSASend( sock, &sendBuf, 1, &dwBytes, 0, &recvOv, SendComplete );
 
And process the buffer in your lpCompletionRoutine callback
WSARecv[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi Gokulnath,
 
As per your comments one way is
1) Read the file that you download in a buffer and than delete it.
and
2) I am not sure about this but I found one API
 
InternetReadFile ->[^]
 
Example ->[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 24 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100