Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

File handler

Posted on 2000-03-24
3
Medium Priority
?
289 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 50 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

782 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