Click here to Skip to main content
Click here to Skip to main content

FTP client library for C#

, 27 Mar 2003
Rate this:
Please Sign up or sign in to vote.
FTP client library for C#, including asynchronous operations.


Finding a fully working, lightweight FTP client, that had no GUI, was free, and came with source code, was difficult. This API is based on a work, Jaimon Mathew had done, and I have added some methods, cleaned up the code, debugged it and added some error handling, logging, debugging etc.

It is easy to use. Here is a code example:

FtpClient ftp = new FtpClient(FtpServer,FtpUserName,FtpPassword);

Not so difficult now, is it? I am using it in my WebCamService list on this site, so if you want to see it in action, go here.

I started out wrapping fully the WinInet API, but it was such a labourous task that it made sense just to do the FTP. Since Microsoft has great support for HTTP, I could skip that, and later work on SMTP.


  • Upload
  • Recursive upload
  • Download
  • Resume
  • Delete
  • Rename
  • Create directory
  • Asynchronous operation


  • Not fully tested
  • No real error handling
  • No download recourse yet
  • Rename will overwrite, if the target already exists

Asynchronous operation

A little more advanced, the asynchronous operation is used when you need the job, to fork while your code continues over the method. All asynchronous methods start with Begin.

Using it is simple. You need a couple of things, an AsyncCallback object and a method which it handles.

private FtpClient ftp = null;

private void UploadPicture(string imagePath)
    string FtpServer = ConfigurationSettings.AppSettings["FtpServer"];
    string FtpUserName = ConfigurationSettings.AppSettings["FtpUserName"];
    string FtpPassword = ConfigurationSettings.AppSettings["FtpPassword"];

    AsyncCallback callback = new AsyncCallback(CloseConnection);

    ftp = new FtpClient(FtpServer,FtpUserName,FtpPassword);
    ftp.BeginUpload(imagePath, callback);

private void CloseConnection(IAsyncResult result)

    if ( ftp != null ) ftp.Close();
        ftp = null;

When the upload finishes or throws an exception, the CloseConnection method will be called.


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


About the Author

Dan Glass
Australia Australia

Comments and Discussions

QuestionRipoff PinmemberMember 1090501527-Jan-15 23:48 
QuestionLicense for usage Pinmemberrahulsia817-Aug-14 19:11 
QuestionCan FTPClient library works with proxy server Pinmemberhkshahasane14-May-14 1:21 
SuggestionProblem of performance PinmemberMember 857641628-Jan-13 1:08 
GeneralMy vote of 5 PinmemberDametry18-Dec-12 17:55 
QuestionWhere can I download the library? Pinmembercathy liang18-Aug-12 20:04 
QuestionError Async Download!!! PinmemberEdward Vargas28-Mar-12 10:53 
QuestionProblem using FTP Client on machines with Norton 360 Antivirus software Pinmemberandreyakub24-Oct-11 22:48 
GeneralFix error "Object reference not set to an instance of an object" when using class FtpWebRequest on Net 4.0 Pinmemberqdhoang8-Mar-11 22:31 
GeneralGood work Pinmemberlapeau21-Sep-10 4:08 
GeneralProblem With IPv6 and Possible Solution PinmemberGaroRobe15-Sep-10 15:34 
GeneralError while uploading large files. Pinmemberfaisaliqbalch14-Apr-10 7:37 
I am getting following error while uploading big file like a file of size 50MB

the connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few
* If you are unable to load any pages, check your computer's network
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.
GeneralQuick Question Pinmembervijayr8-Apr-10 4:04 
GeneralRe: Quick Question Pinmemberdaveauld9-Apr-10 3:03 
QuestionError When Trying Login PinmemberSibiSurya13-Jan-10 22:36 
Questiondownload problem Pinmembernew start6-Nov-09 1:19 
AnswerRe: download problem Pinmembernew start6-Nov-09 1:40 
GeneralThanks dude Pinmemberfeisal30-Sep-09 6:17 
QuestionThe Max number of Uploaded files Pinmemberfhy1977022729-Jul-09 21:46 
Rantdownload doesnt work Pinmemberprozomg8-Jan-09 6:03 
GeneralRe: download doesnt work PinmemberEdward Vargas28-Mar-12 10:57 
Generalthis ftpserver is good! Pinmemberhouzhifa9-Oct-08 2:02 
Generalthis message Pinmemberyudi01024-Sep-08 21:43 
GeneralA comfortable FTP class in .NET PinmemberElmue27-Aug-08 13:16 
QuestionSecur Connection PinmemberSaeidehV11-Sep-07 21:35 
AnswerRe: Secur Connection Pinmemberkorrawit6-Nov-07 8:51 
QuestionPossibility to use QUOTE RCMD SBMJOB CMD()? Pinmemberpaoloden6-Jan-07 1:58 
Questionhow to run with chinese file and folder name Pinmemberfnjcr7-Dec-06 20:36 
AnswerRe: how to run with chinese file and folder name Pinmembertianjh838-Feb-07 17:01 
GeneralRe: how to run with chinese file and folder name Pinmemberfhy197702277-Jul-09 20:04 
GeneralRe: how to run with chinese file and folder name Pinmemberfhy1977022729-Jul-09 21:29 
QuestionHow can I use "BeginGetFileList"? Pinmemberwolfs21-Sep-06 5:56 
AnswerRe: How can I use "BeginGetFileList"? Pinmemberwolfs25-Sep-06 17:16 
GeneralRe: How can I use "BeginGetFileList"? Pinmemberendy28-May-07 22:37 
Questionupload images in bad resolution!!! Pinmemberhamid_m20-Sep-06 14:05 
QuestionHow to Download file from Ftp server Pinmembercscrazy3-Aug-06 18:30 
GeneralView a list of files Pinmemberfetty41010-Jan-06 2:44 
GeneralRe: View a list of files Pinmemberbianyb19-Jul-07 21:51 
GeneralDon't loose your time... Pinmembertiusho30-Nov-05 23:27 
GeneralRe: Don't loose your time... PinmemberJeff Firestone2-Dec-05 8:18 
GeneralRe: Don't loose your time... Pinmemberthirteenthmonth4-Jan-07 18:26 
GeneralRe: Don't loose your time... PinmemberNiklas Henricson7-May-09 1:24 
GeneralRe: Don't loose your time... Pinmembernietzsche4413-Sep-07 23:19 
GeneralRe: Don't loose your time... Pinmemberjay_t5516-Jan-10 20:43 
Generalerror,while ftp.GetFileList(); Pinmemberlovemory23-Aug-05 18:50 
AnswerRe: error,while ftp.GetFileList(); PinmemberSprotty11-Oct-05 1:13 
GeneralRe: error,while ftp.GetFileList(); PinmemberPatrice Dargenton27-Jun-06 1:40 
GeneralRe: error,while ftp.GetFileList(); Pinmembertmck7-Mar-07 6:25 
GeneralRe: error,while ftp.GetFileList(); Pinmemberti_hugo31-May-07 2:31 
GeneralRe: error,while ftp.GetFileList(); PinmemberPatrick Mortara20-Nov-07 7:25 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150301.1 | Last Updated 28 Mar 2003
Article Copyright 2003 by Dan Glass
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid