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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds