Click here to Skip to main content
15,860,972 members
Articles / Desktop Programming / MFC
Article

FTP Wanderer - FTP Client using WININET

Rate me:
Please Sign up or sign in to vote.
4.85/5 (49 votes)
30 Jul 20023 min read 306.4K   19.7K   112   63
This article presents a fully functional implementation of a FTP client.

Sample Image

Description

This article presents a fully functional implementation of a FTP client. FTP Wanderer is a multithreaded FTP client with the look-and-feel of Windows Explorer, and makes moving files between the Internet and your computer as simple as local file manipulation. This application uses WININET API's to handle the FTP protocol, and while it's not the most elegant way to connect to a FTP server it does the job pretty well.

Features list

  • All file transfer requests are handled in the background, so you don't have to wait while files copy to continue browsing the current server. You can even connect to a different server, while file transfers on another server are still in progress.
  • The Transfer Manager shows all file transfers currently in progress plus the ones that are in the queue. You can configure how many transfers are processed simultaneously, so you don't run out of resources.
  • FTP Wanderer uses the Windows 9x/NT/XP style list boxes for displaying the contents of remote servers. With all familiar system icons and context menus.
  • You can specify the number of times it should try to connect, and the time delay between connection attempts.
  • Full Drag and Drop support. Simply drag one or more files or even complete folders onto FTP Wanderer's file view area to transfer them to the location of the server that is currently connected.
  • Easily configure FTP site settings, like username, password, port, initial remote folder, number of retries and default download folder.

Here's a brief description of some of the important classes of the application:

CMainFrame

CMainFrame contains most of the code for managing the FTP connection. It takes care of connecting to the server; initiate up/downloads and handling other FTP related actions.

CFTPListView

This is just a CListView derived class that takes care of displaying the files and enabling you to sort them. When the application is busy downloading or sorting a directory listing it can display an animation, just like explorer does.

CConnectDlg

This class (= Site Manager) enables the user to manage FTP sites. You can add/change and delete sites and configure properties such as hostname, port, username and password. The settings of each site are save to disk using serializing.

CTransferManagerDlg

CTransferManagerDlg (= Transfer manager) takes care of queuing the file transfers. It shows all file transfers currently in progress plus the ones that are in the queue. You can configure how many transfers are processed simultaneously, so you don't run out of resources. Each up/download in handled in a separate thread by initiating a CDownloadThread or CUploadThread thread.

CDownloadThread

Each download is handled in the background using a separate thread. CDownloadThread creates a new connection with the FTP server and displays a progress dialog that tells you the status of the file transfer. When the download is completed (or aborted) it notifies the transfer manager so the UI can be updated.

CUploadThread

Each upload is handled in the background using a separate thread. CUploadThread creates a new connection with the FTP server and displays a progress dialog that tells you the status of the file transfer. When the upload is completed (or aborted) it notifies the transfer manager so the UI can be updated.

To do list:

While this application has most of the features you might expect in a FTP client, there are a few things left to do:

  • Drag and drop support out of the file view area to Explorer. I think this one is not that easy, because this would probably 'block' explorer until the file transfer is completed (any suggestions?).
  • Progress indication in the transfer manager. This is not really that hard to do, so this will probably be in the next release.
  • Better asynchrony handling of getting directory listing. The UI now does not respond when downloading a huge directory listing.

Contacting the Author

Please send any comments or bug reports to me via email. For any updates to this article, check my site here.

Revision history

  • 31st July 2002 - Initial revision.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
PraiseGreat job,Thanks a lot! Pin
Member 128645533-Jan-17 3:08
Member 128645533-Jan-17 3:08 
Questionbug: assertion occurs Pin
bln13fb4-Mar-13 23:07
bln13fb4-Mar-13 23:07 
GeneralMy vote of 5 Pin
ytfrdfiw31-Oct-12 21:51
ytfrdfiw31-Oct-12 21:51 
Questionhow to debug and compile in vs2008 Pin
ytfrdfiw31-Oct-12 21:51
ytfrdfiw31-Oct-12 21:51 
Generalc# or VB Pin
colorbaby29-Oct-09 7:16
colorbaby29-Oct-09 7:16 
Questionhow to mark when a download is finished Pin
flyras22-Aug-09 23:01
flyras22-Aug-09 23:01 
GeneralA comfortable FTP class in .NET Pin
Elmue27-Aug-08 12:15
Elmue27-Aug-08 12:15 
QuestionQuestion Pin
Alireza_136210-Feb-08 21:44
Alireza_136210-Feb-08 21:44 
QuestionCInternetSession Setting problem Pin
Cem Usta17-Aug-07 2:20
Cem Usta17-Aug-07 2:20 
Questiontwo errors when i compline the source use visual studio 2005? Pin
xinmans13-Apr-07 0:02
xinmans13-Apr-07 0:02 
GeneralGreat Job !!! Hats off Pin
sridharraov22-Feb-07 4:09
sridharraov22-Feb-07 4:09 
GeneralDrag and Drop Problem Pin
codepanter25-Sep-06 23:35
codepanter25-Sep-06 23:35 
GeneralThis might be the greatest article on this site Pin
Programm3r22-Aug-06 20:39
Programm3r22-Aug-06 20:39 
Generalwow... Pin
jimbo_azim12-Jul-06 22:10
jimbo_azim12-Jul-06 22:10 
QuestionWinInet FTP - how to dump each conversation ? Pin
rrrado30-Nov-05 4:21
rrrado30-Nov-05 4:21 
QuestionHow to implement security in FTP Pin
rm_pkt4-Oct-05 3:08
rm_pkt4-Oct-05 3:08 
QuestionAPPEND feature for FTP? Pin
Lowell20-Sep-05 9:35
Lowell20-Sep-05 9:35 
AnswerRe: APPEND feature for FTP? Pin
Pablo Software Solutions20-Sep-05 9:38
Pablo Software Solutions20-Sep-05 9:38 
GeneralRe: APPEND feature for FTP? Pin
Lowell21-Sep-05 8:37
Lowell21-Sep-05 8:37 
GeneralRe: APPEND feature for FTP? Pin
Pablo Software Solutions21-Sep-05 9:27
Pablo Software Solutions21-Sep-05 9:27 
GeneralThere are two bugs with your Ftp Wanderer Pin
siduizhangjian@hotmail.com26-May-05 14:52
siduizhangjian@hotmail.com26-May-05 14:52 
GeneralRe: There are two bugs with your Ftp Wanderer Pin
Pablo Software Solutions26-May-05 19:44
Pablo Software Solutions26-May-05 19:44 
GeneralRe: There are two bugs with your Ftp Wanderer Pin
TuPacMansur8-Jan-06 8:54
TuPacMansur8-Jan-06 8:54 
GeneralResources Pin
bluecoolz23-Nov-04 20:23
bluecoolz23-Nov-04 20:23 
Generalproxy Pin
sway19-Nov-04 20:38
sway19-Nov-04 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.