Upload and Download a File to Ftp server through FTPClient Using C#
Today i want to discuss an article to upload a file through Ftp Client in C# which is an another Alternative to fileupload Control and WebClient Class. How it works i will illustrate with Code snippets.
Today i want to discuss an article to upload a file through Ftp Client in C# which is an another Alternative to fileupload Control and WebClient Class. How it works i will illustrate with Code snippets.
Some times we are given a task to move the Files from one Location to another Location with in Local Computer or Remote Computer and Many Programmers ask in Forum discussions how to relocate the Files from one Computer to another Computer or with in the Local computer. There are two ways to do it
1) using WebClient.UPloadFile ---- as discussed in Previous Article
2) Another is FtpClient . How to work with this Ftp Client
In FTPCLIENT CLASS will be in System.Net as like WebClient
In FtpClient class Upload is the Method in C# that uploads the File in ftpserver....
First create an instance of ftpClient and call the Parameterised Constructor
FtpClient ftpclnt = new FtpClient("ftp://serevername",username, password )
ftpClnt.Upload(path of the Image/filename)
ftp.Close();
You can get all files in the Directory with this Piece of Code
FtpDirectory ftpdirect = myFtp.GetDirectory("/pub");
You can Use like this
Foreach( FTPfileinfo ftp in myFtpGetDirectory("/bin").GetFiles)
{
myftp.Download("file","location of the file")
}