Click here to Skip to main content
Licence CPOL
First Posted 24 Apr 2007
Views 111,303
Downloads 1,116
Bookmarked 121 times

C# FTP Client Library

By | 23 May 2007 | Article
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)

About the Author

jmers

Web Developer

Anonymous Proxy Anonymous Proxy

Member

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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to check if the connection is established? PinmemberAnLa0610954:08 27 Jun '11  
GeneralAlex FTPS Client PinmemberB.Ritter0:09 5 Mar '11  
Generalexpect a demo Pinmemberpclion22:55 13 Feb '11  
GeneralNot work in download .. PinmemberAlexB477:33 12 Feb '11  
GeneralBug solutions Pinmemberrobnet0:28 17 Aug '10  
GeneralRe: Bug solutions PinmemberB.Ritter6:37 1 Nov '10  
QuestionI cannot get the listing of the files plus other bugs PinmemberEvandrojr10:22 2 Mar '10  
GeneralActive Mode Pinmemberliglio14:33 27 Jan '10  
GeneralRe: Active Mode Pinmemberjmers17:13 27 Jan '10  
GeneralRe: Active Mode Pinmemberliglio3:13 28 Jan '10  
GeneralRe: Active Mode PinmemberDaniel Castenholz8:22 29 Jan '10  
QuestionSocketException Error Code 11004 PinmemberZac Greve10:54 10 Jan '10  
AnswerRe: SocketException Error Code 11004 Pinmemberjmers15:18 10 Jan '10  
Questionupload folder PinmemberDirekt20074:07 18 Nov '09  
GeneralCF 3.5 PinmemberGateone752:32 12 Aug '09  
RantLOL PinmemberSeishin#2:01 8 Apr '09  
GeneralRe: LOL PinmemberPhylum1235:25 22 Oct '09  
GeneralExceoption when trying to upload [modified] PinmvpJohn Simmons / outlaw programmer11:52 8 Jan '09  
QuestionHow to connect to two FTP Servers PinmemberLearnNetnAll21:59 15 Dec '08  
GeneralA socket operation encountered a dead network Pinmemberjosephx2k712:41 15 Dec '08  
Generalgood library Pinmemberemilioarp7:30 12 Nov '08  
Generalconnection was forcibly closed by the remote host at System.Net.Sockets. Pinmembernext100years0:55 11 Nov '08  
GeneralA comfortable FTP class in .NET PinmemberElmue12:22 27 Aug '08  
GeneralChangeDirectory Chrash PinmemberMember 425415211:52 1 May '08  
GeneralRe: ChangeDirectory Chrash Pinmemberjmers9:36 3 May '08  

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.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 23 May 2007
Article Copyright 2007 by jmers
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid