CFtpGet - FTP File Retrieval Class

Environment: Windows 98, Visual C++ 6

I created this class because I needed a class to allow me to synchronize my local system with files on a remote system. At first, I looked to MSDN for help, but couldn't get their examples to work. Then, I looked to CodeGuru for assistance. I posted the question of how to retreive a file using FTP and Ken Sutherland was able to help me.

The source code he gave me worked for only one file transfer at a time so I modified it for my purpose so that it allows for up to 100 files to be transferred on one operation.

CFtpGet Class Definition

// ftpget.h

class CFtpGet
public:// function, in logical order
 virtual ~CFtpGet();

 // password & user name
 bool SetAccessRight(CString userName,CString userPass);

 // open the connection
 bool OpenConnection(CString server);

 // only one file
 bool GetFile(CString remoteFile,
 CString localFile);

 // a full CString array
 int GetMultipleFile(CStringArray *remoteArray,
                     CStringArray *localArray,
                     int number_file);

 // close the connection
 bool CloseConnection();

private: // var
 CInternetSession *pInternetSession;
 CFtpConnection *pFtpConnection;
 CString strServerName;
 CString strPass;
 CString strUser;

 CString strAppName;
 bool missed[100];

Using the CFtpGet Class

To transfer a single file...
CFtpGet ftp; //start the class
ftp.SetAccessRight("username","userpassword");// set user and pasword
bool good = ftp.OpenConnection("server");// the name of the server

if (!good)


// see GetMultiplefile below
To transfer multiple files...
CStringArray remote;
CStringArray local;



This is my first Itnernet file transfer class and I'll try to embelish this class as time permits.


Download demo project - 8 Kb
Download source - 16 Kb


  • Error

    Posted by Legacy on 07/24/2002 12:00am

    Originally posted by: Mathias

    After a ftp connection is open, it could�t close correctly ....
    So ... if you want to reconnect , the older connection will cause problems....

  • CInternetSession() argument missing

    Posted by Legacy on 01/11/2002 12:00am

    Originally posted by: Keith Berson

    Maybe it's new with version 6.0 of Visual Studio, but I show the second argument of CInternetSession() as being the context. You have


    and it should be


    Of course, this only matters if you are looking to use CInternetSession::OnStatusCallback(), as the default value for the CInternetSession() is INTERNET_OPEN_TYPE_PRECONFIG.


  • FTP (intranet) to use as Command line argument

    Posted by Legacy on 06/13/2001 12:00am

    Originally posted by: Guru

    How to use FTP in intranet with command line argument...
    any help in this will be appreciated.....
    Thanx in advance

  • Nice and simple but...

    Posted by Legacy on 06/12/2001 12:00am

    Originally posted by: Bev

    Nice and simple but the example only works if I try to retrieve from the root directory of the ftp server.

    Anything in a lower directory is reported as missing.

    Am I missing something?



  • Retreive file attributes from remote system

    Posted by Legacy on 06/05/2001 12:00am

    Originally posted by: Gaby NGONGO

    Is it possible to retreive only those files that are not opened ? In other words, is it possible to read file attributes from the remote system ?

  • How can I use different Codepages?

    Posted by Legacy on 03/17/2001 12:00am

    Originally posted by: Gerald Harte


    i use the Visual C++ 6 FTP-Classe to get some File file from a mainfraime!
    But i have one Problem. The mainfraime does use a different codepage as the PC.
    If you take the DOS-FTP under Windows NT, you can use the command 'quote site sbdataconn=(ibm-273)'!
    I have not find out, where i can use this command under MFC!
    Maybe you have got a idea?

    Gerald Harte

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date