Transfer Files to and from an FTP Server

Click here for a larger image.

Environment: Visual C++

Transferring files to and from the server is easily automated using MFC classes. Here I have provided the full source code to do file transfers from and to the FTP servers. I have provided and arranged the code in such a way that it is possible to transfer a complete directory or drive to the server.

The application that transfers the files will give a list of local drives in the system. After you Connect to the FTP server, it connects to the root of the server. Then the root items can be expanded and the required file transfer can be performed. It resembles the Explorer window.

It uses the MFC class CFtpConnection and CInternetSession to achieve the file transfer.


Download source -- 29 Kb

About the Author

Vinoj Kumar

I have been programming for the past 16 years. I started programming in 1990. I came to Windows in 1993. I have authored a book called, "Classic Utilities Using Assembly Language" , 1995. In my free time I listen a lot to Kenny G sax all the albums and Valentine Classics Songs. I like to watch a lot of TinTin adventure Comics. I am currently working in K7 Computing antivirus company ( as Senior Technical Lead. My contact is: Phone: +91 944 411 7353


  • update the source file,it is not working

    Posted by Legacy on 09/05/2003 12:00am

    Originally posted by: Dinesh


    Update the source file, it is not working

  • OpenFile failure

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

    Originally posted by: Tim Bendon

    When running this example on and FTP server the call to OpenFile always fails. Anybody familair with this problem?



  • VC++ + FTP

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

    Originally posted by: abeezar

    Would like to know how to use auto re-connect when fTP connection is lost.


  • Pc to WorkSatation problem

    Posted by Legacy on 09/26/2002 12:00am

    Originally posted by: Bruno

    Good Job but when I try to download a file from Pc to WorkSatation an error occurs
    550 /hostdir/myfile not a plain file
    550 /hostdir/myfile no such file or directory

    Why it Happen ?

  • Expansion problem

    Posted by Legacy on 06/19/2002 12:00am

    Originally posted by: Jim Altemose

    This is most excellent and useful.  Thanks.

    I agree that there appears to be a bug with expanding a remote sub-directory. I believe the problem lies in LeftView.cpp with the following code:

    while (true)
    hTC = TreeCtrl->GetParentItem(hTC);

    if (hTC != TreeCtrl->GetRootItem()){
    Tmp = TreeCtrl->GetItemText(hTC);
    //? if(strcmp(Tmp, "/") == 0)
    //? break;
    Dir = Tmp+"/"+Dir;
    Dir += "/*";

    Commenting out the two lines marked '//?' appears to fix the problem for me. On the ftp server I'm connecting to, I have a 'usr' directory with a 'users' sub-directory. On the first pass through OnItemexpanding(), Dir='//*', which is fine. Expanding 'usr' yields Dir='usr/*', which is not fine. Commenting out the above test yields Dir='//usr/*', which is good. But, I'm guessing I've just broken something else.

    This is an excellent program, and I plan to expand on it for my own purposes. I'll be happy to help test any features and bug fixes you might have.

    - Jim

  • Excellent Work , But Some problem

    Posted by Legacy on 06/17/2002 12:00am

    Originally posted by: Sujit

    It's really a good work Vinoj.
    But when I am trying to expand some of the folder
    in the left window I am unable to do so. Can you please
    let me know how this problem can be solved.

    And also one more request , suppose I want to go to the
    Home directry of the server(Presently it always go to root)
    login when I Connect to Remote server ,
    can you pls let me know how can it be done.

    And aslo as we can connect to multiple server here ,
    So how can we show the server name in the explorer left window.

  • need some help here.

    Posted by Legacy on 06/16/2002 12:00am

    Originally posted by: vik

    nice work with ur FTP.
    i need a report on it for submission.
    could u pls mail it to me,
    thank u,

  • There's a problem

    Posted by Legacy on 06/14/2002 12:00am

    Originally posted by: Alexi Jordanov

    I can expand some of directories of solaris ftp server. I don't have such a ptoblem with BulletProof FTP client or any other FTP client.

    For example I try to expand "export" node. I see it's subfolder "home" in right view but node is not expanded.

    Also I think that it'll be a good idea to add in explorer ( is example how you can add bars in it. For my sorrow I don't know how you can add tree nodes in "Folders" bar. If someone knows let help you)

    Regards, Alex

  • What about file-resume?

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

    Originally posted by: Chris

    Know how to implement file-resume?

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

Top White Papers and Webcasts

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

  • 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 …

Most Popular Programming Stories

More for Developers

RSS Feeds

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