Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File handler

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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 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.

722 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