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

C# FTP Client Library

, 23 May 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
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):

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)

Share

About the Author

jmers
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

 
QuestionThank you PinmemberJason asdf29-Apr-14 12:52 
QuestionHow to check if the connection is established? PinmemberAnLa06109527-Jun-11 5:08 
GeneralAlex FTPS Client PinmemberB.Ritter5-Mar-11 1:09 
Generalexpect a demo Pinmemberpclion13-Feb-11 23:55 
GeneralNot work in download .. PinmemberAlexB4712-Feb-11 8:33 
GeneralBug solutions Pinmemberrobnet17-Aug-10 1:28 
GeneralRe: Bug solutions PinmemberB.Ritter1-Nov-10 7:37 
QuestionI cannot get the listing of the files plus other bugs PinmemberEvandrojr2-Mar-10 11:22 
GeneralActive Mode Pinmemberliglio27-Jan-10 15:33 
GeneralRe: Active Mode Pinmemberjmers27-Jan-10 18:13 
I'm really not sure, the ftplib was a basic class for accessing an FTP, I simply wrote a wrapper around it with methods and properties to make it easier to use. The underlying code didn't really change so if the functionality was there before it should still be there, or at least be accessible.
 
Jmers

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
Web04 | 2.8.141220.1 | Last Updated 23 May 2007
Article Copyright 2007 by jmers
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid