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

FTP Operation in a simple way...

, 15 Mar 2007
Rate this:
Please Sign up or sign in to vote.
code FTP Operation in just 4-5 lines...


This article will enable you to write FTP operation in just 5 minutes...

We know that FTP same as direcotry structure which we have on our system, but the difference is that FTP directory is located at some other place.

So when you upload afile you are transfering one file from one place to another, just like in Unix programming, if we want to copy one file from one place to another we


for more Information about Class used in this article Please refer MSDN...

Using the code

you just have to copy and paste this code into your code and that will able to upload or download files from the FTP specified by you...

// Just Rename File name and FTP location that you want to upload or download.
//Generate the File name which you want to upload on the FTP... 
string ftpFilename = ftpServer + FileName;

//Create a Object of class WebClient.. 
WebClient client = new WebClient();
//Give the Credincials which will help you to enter into the FTP..

client.Credentials = new NetworkCredential(loginName, ftpPwd);

//Now use .UploadFile Method of WebClient Object to upload the file,
this method will return response from the FTP server which you can use as, 
result of FTP operation.. 

responseArray = client.UploadFile(ftpFilename, filetobeUploaded); 
//here you have to pass full path of FTP directory with filename included as
 ftpFilename, like if you want to upload file to then
use this kind of structure..
ftpFilename = "";
//and in the 'filetobeUploaded' give name of your file to be uploaded..
//same way you can download the file by using .downloadfile method of the 
Webclient class Object.
//so enjoy the FTP operation in just 5 minutes..

Points of Interest

I like to Share my knowledge with guys like you, because i am also one of you, that if i dont know anything then i come to keep exchange of knowledge...


If i find any shorter method of FTP then defenetly i will add that in this article...


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

Software Developer
India India
Chirag Patel, a Programmer Analyst in a well known IT company working on .NET Technologies since last 2 years. He is interested in Pure business logic and fuzzy logic. his area of interest is in C#.NET, VB.NET and MSSQL 2005.
catch me on:

Comments and Discussions

Generalftp and progress bar PinmemberSuperBlois18-Mar-08 8:05 
GeneralRe: ftp and progress bar PinmemberJustChiragPatel18-Mar-08 19:01 
SuperBlois wrote:
How can i use a progress bar with your code?

we are using this function to upload file,
responseArray = client.UploadFile(ftpFilename, filetobeUploaded);
so, if you want to show progress bar then take this function event into one Asynchronous "Begin" event and start showing your progress indicator, and at the time you reach at "End" event then stop showing that progress indicator.
for more help about "Begin" and "End" asynchronous events, please see MSDN.
Thanks. Big Grin | :-D
Chirag Patel
Programmer Analyst

QuestionUpload files when behind a proxy PinmemberShinuda17-Oct-07 22:08 
Questionerror while downloading file from ftp PinmemberProsGIS30-Aug-07 5:23 
GeneralInternal Server Error PinmemberFact Pandit14-May-07 17:37 
GeneralRe: Internal Server Error PinmemberJustChiragPatel20-May-07 21:06 
GeneralRe: Internal Server Error PinmemberFact Pandit13-Jun-07 11:40 

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
Web01 | 2.8.150326.1 | Last Updated 15 Mar 2007
Article Copyright 2007 by JustChiragPatel
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid