locked
How to download a zip file from FTP using C#? RRS feed

  • Question

  • Hello All,

               I am trying to download a zipped file from FTP site using C#.

    I am using the following Code:

     

    try
    
       {
    
       FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://FILEPATH/FILENAME.zip"
    );
       request.Method = WebRequestMethods.Ftp.DownloadFile;
    
       request.Credentials = new
     NetworkCredential(""
    , ""
    );
    
       FtpWebResponse response = (FtpWebResponse)request.GetResponse();
           
        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new
     StreamReader(responseStream);
    
        MessageBox.Show(reader.ReadToEnd().ToString());
    
        reader.Close();
    
        response.Close(); 
      
    Console.WriteLine(reader.ReadToEnd()); } catch (NotSupportedException ne) { MessageBox.Show(ne.Message); }

    I am getting encrypted text as the output.

    Please Help me to fix this problem.

    _

    Thanks,

    Sid

     

    Monday, June 28, 2010 11:22 PM

Answers