Click here to Skip to main content
15,881,746 members
Articles / Programming Languages / C#

C# FTP Client Library

Rate me:
Please Sign up or sign in to vote.
4.65/5 (24 votes)
23 May 2007CPOL1 min read 263.1K   4.3K   124   83
Easy to use FTP client library with features in mind.

Introduction

This code is an FTP class library for adding FTP access to your projects. It is heavily based on a project (see background for original code), and is now contained in the source files. I was not sure how to update the original article or add to it so I am publishing this as a new article since there was an extensive re-work of the original code in an attempt to make it more developer-friendly.

Background

This article, and code, are based upon the ftplib posted by J.P. Trosclair. A link to the article is here. I have left original copyright and credit notices in with the updated version of the code.

Using the code

I used nDoc to create a CHM file (in the doc directory of the code) to help with implementation. Its fairly simple, and you will mainly need basic FTP connection information (IP, username, etc.) to use the library.

An example is included in the documentation, and appears as so (to upload a file):

C#
OpenFTP.FTP f = new OpenFTP.FTP();
f.Connect("127.0.0.1", "username_here", "password_here");
f.ChangeDirectory("somedirectory");
f.Files.Upload(Path.GetFileName(sFileName), Path.GetFileName(sFileName));

while (!f.Files.UploadComplete)
{
    Console.WriteLine("Uploading: TotalBytes: " + 
        f.Files.TotalBytes.ToString() + ", : PercentComplete: " + 
        f.Files.PercentComplete.ToString());
}
Console.WriteLine("Upload Complete: TotalBytes: " + 
    f.Files.TotalBytes.ToString() + ", : PercentComplete: " + 
    f.Files.PercentComplete.ToString());

f.Disconnect();
f = null;

Points of Interest

I liked the original article but decided that even though I could read and implement the code I wanted its implementation to be more simplistic so months later I won't have to re-read any code to figure how to include the methods in a new project. I have tried to remove the rough edges.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Anonymous Proxy Anonymous Proxy
I am a Senior-level .NET developer using C# for about 5+ years now.

Codeproject has been a tremendous resource for me over the years.

Comments and Discussions

 
GeneralRe: List Directories Pin
jmers24-Oct-07 5:38
jmers24-Oct-07 5:38 
GeneralRe: List Directories Pin
idanz24-Oct-07 22:01
idanz24-Oct-07 22:01 
GeneralUpload Read-Only Files Pin
CP_Sjarel27-Sep-07 3:43
CP_Sjarel27-Sep-07 3:43 
GeneralRe: Upload Read-Only Files Pin
jmers27-Sep-07 3:46
jmers27-Sep-07 3:46 
GeneralProxy Pin
andrushik17-Jul-07 0:55
andrushik17-Jul-07 0:55 
GeneralRe: Proxy Pin
jmers18-Jul-07 6:10
jmers18-Jul-07 6:10 
QuestionNo FTP Mode in your project? Pin
daveberlin30-May-07 8:14
daveberlin30-May-07 8:14 
AnswerRe: No FTP Mode in your project? Pin
jmers30-May-07 9:08
jmers30-May-07 9:08 
GeneralRe: No FTP Mode in your project? Pin
daveberlin30-May-07 9:59
daveberlin30-May-07 9:59 
AnswerRe: No FTP Mode in your project? Pin
jmers30-May-07 10:35
jmers30-May-07 10:35 
GeneralRe: No FTP Mode in your project? [modified] Pin
daveberlin30-May-07 10:47
daveberlin30-May-07 10:47 
GeneralCan't get it to (fully) work [modified] Pin
flxfxp29-May-07 13:15
flxfxp29-May-07 13:15 
GeneralRe: Can't get it to (fully) work Pin
Martin#29-May-07 22:32
Martin#29-May-07 22:32 
GeneralRe: Can't get it to (fully) work Pin
Morningkill31-Mar-08 6:46
Morningkill31-Mar-08 6:46 
QuestionBug when disconnecting? Pin
endy24-May-07 4:19
endy24-May-07 4:19 
AnswerRe: Bug when disconnecting? Pin
jmers30-May-07 9:32
jmers30-May-07 9:32 
AnswerRe: Bug when disconnecting? Pin
endy30-May-07 21:52
endy30-May-07 21:52 
GeneralRe: Bug when disconnecting? Pin
jmers31-May-07 2:05
jmers31-May-07 2:05 
GeneralRe: Bug when disconnecting? Pin
agadzhanov8-Sep-08 3:41
agadzhanov8-Sep-08 3:41 
GeneralSweet! Pin
thund3rstruck24-May-07 4:08
thund3rstruck24-May-07 4:08 
GeneralGreat Job Pin
merlin98123-May-07 11:57
professionalmerlin98123-May-07 11:57 
GeneralPROBLEM Pin
Novacaine12-May-07 2:21
Novacaine12-May-07 2:21 
AnswerRe: PROBLEM Pin
jmers16-May-07 8:40
jmers16-May-07 8:40 
GeneralA workaround... [modified] Pin
endy24-May-07 2:31
endy24-May-07 2:31 
GeneralThank you! Pin
superdennis16-Apr-08 0:53
superdennis16-Apr-08 0:53 

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.