Solved

File handler

Posted on 2000-03-24
3
263 Views
Last Modified: 2010-04-02
Hullo,

When using the OpenUrl function in MFC it returns a file handler as follows

Returns a file handle for FTP, GOPHER, HTTP, and FILE-type Internet services only. Returns NULL if parsing was unsuccessful.

The pointer that OpenURL returns depends on pszURL’s type of service. The table below illustrates the possible pointers OpenURL can return.

URL type Returns
file:// CStdioFile*
http:// CHttpFile*
gopher:// CGopherFile*
ftp:// CInternetFile*

When I have this I want to read the file into an array.
Any ideas on how i might do this?
the handler in this case will be CHttpFile as it is a file I am reading from a http site.

thanks
0
Comment
Question by:sambo12
3 Comments
 
LVL 9

Expert Comment

by:Pacman
ID: 2653602
Can't you just read the bytes via member function "Read()" ?
0
 

Expert Comment

by:maxd128
ID: 2655635
Simply asign returned pointer to CFile* and use it's member functions.
0
 

Accepted Solution

by:
vidz7 earned 25 total points
ID: 2772906
hi sambo..... hope this helps u:

CInternetSession is;
      CHttpConnection *hc;
      CHttpFile *hf;
      DWORD dwRead;
      BYTE buffer[6000];      
      CFile lf("try.zip",CFile::modeCreate | CFile::modeWrite );
      
      try
      {
            hf=(CHttpFile*)is.OpenURL("GIVE UR URL HERE...eg: http://microsoft.com/dirmap.txt",1,INTERNET_FLAG_TRANSFER_BINARY);
                        
         dwRead = hf->Read(buffer,hf->GetLength());
             lf.Write(buffer, dwRead);
            
        AfxMessageBox("Done");


      }
      catch(CInternetException ex){AfxMessageBox("BOMBED");}
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

708 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

13 Experts available now in Live!

Get 1:1 Help Now