Some of you already know that the .NET Framework v2.0 supports FTP, so this may not be new to all of you. The FtpWebRequest class makes it easy to upload and download files to an FTP server.
The class functions similarly to the HttpWebRequest class.
You open a connection by using WebRequest.Create().
// create a new request and cast it to ftp
FtpWebRequest ftpWebRequest = (FtpWebRequest)WebRequest.Create(serverUri);
// set the credentials
ftpWebRequest.Credentials = new NetworkCredential ("anonymous","blah@blah.com");
Strangely enough, the example I have seen uses the DownloadData() method to download a file, but this method is mentioned nowhere in the documentation. So I have no idea if it works or not. If anyone tries it, please let me know.
byte [] newFileData = request.DownloadData (serverUri.ToString());
The FtpWebRequest class also supports most typical ftp operations. Secure FTP can be enabled by setting the EnableSsl property to true. Passive mode can be enabled by setting Passive to true.
In turn the FtpWebResponse class can be used to get the status, banner message, etc.
Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=213