Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
is it possible that we can download a file from ftp by using http web request
please send me source code if it is possible
Posted

1 solution

Well that would not seem logical now would it? An FTP protocal request through a HTPP protocol request.

You could look into FtpWebRequest[]

The following code example demonstrates downloading a file from an FTP server by using the WebClient class.

C#
public static bool DisplayFileFromServer(Uri serverUri)
{
   // The serverUri parameter should start with the ftp:// scheme.
   if (serverUri.Scheme != Uri.UriSchemeFtp)
   {
      return false;
   }

   // Get the object used to communicate with the server.
   WebClient request = new WebClient();
    
   // This example assumes the FTP site uses anonymous logon.
   request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

   try 
   {
      byte [] newFileData = request.DownloadData (serverUri.ToString());
      string fileString = System.Text.Encoding.UTF8.GetString(newFileData);
      Console.WriteLine(fileString);
   }
   catch (WebException e)
   {
      Console.WriteLine(e.ToString());
   }

   return true;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900