i m working on web application. i want to download a file from ftp through http webrequest in c#
Source code for downloading file from ftp through httpwebrequest in c#
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

CrishRank #1,487 · 1.1K reputationPosted May 12, 2010, 4:35 AM EDT
use below code for download a file from ftp through http webrequest in c#
using System; using System.IO; using System.Net; using System.Text; namespace Examples.System.Net { public class WebRequestGetExample { public static void Main () { // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm"); request.Method = WebRequestMethods.Ftp.DownloadFile; // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential ("anonymous","[email protected]"); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("Download Complete, status {0}", response.StatusDescription); reader.Close(); response.Close(); } } } thanks