Solved

File handler

Posted on 2000-03-24
3
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

734 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