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: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds