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.

Downloads

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 (www.k7computing.com) as Senior Technical Lead. My contact is: Phone: +91 944 411 7353

Comments

  • update the source file,it is not working

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

    Originally posted by: Dinesh

    haiiii....

    Update the source file, it is not working

    Reply
  • 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?

    thanks

    Tim

    Reply
  • 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.

    Regards
    Abeezar

    Reply
  • 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 ?

    Reply
  • 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)
    break;

    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

    Reply
  • 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.

    Reply
  • need some help here.

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

    Originally posted by: vik

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

    Reply
  • 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 (http://www.codeguru.com/atl/deskband.html 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

    Reply
  • What about file-resume?

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

    Originally posted by: Chris

    Know how to implement file-resume?

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

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds