tags:

views:

672

answers:

1

Error message is:

The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made.

I get this message when I try to call GetResponse() method below... Please help.

Here is my C# code :

FileStream outputStream = new FileStream(feedXmlPath + "\" + "testXml", FileMode.Create);

        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpURL + "/" + zipFileName);

        request.UseBinary = true;

        request.Credentials = new NetworkCredential(userName, password);

        request.KeepAlive = false;

        request.Method = WebRequestMethods.Ftp.DownloadFile;

      FtpWebResponse response = (FtpWebResponse)request.GetResponse();
      Stream ftpStream = response.GetResponseStream();

      long cl = response.ContentLength;
      int bufferSize = 2048;
      int readCount;
      byte[] buffer = new byte[bufferSize];

      readCount = ftpStream.Read(buffer, 0, bufferSize);


        while (readCount > 0)
      {
          outputStream.Write(buffer, 0, readCount);
          readCount = ftpStream.Read(buffer, 0, bufferSize);
      }

      ftpStream.Close();
      outputStream.Close();
      response.Close();
A: 

The use of FTPWebRequest isn't permitted for security reasons if you're using NAT. Check out this post on Connect.

This post on MSDN might be helpful too.

PaulB
thanks paul for ur comments...i tried code mentioned in MSDN link above, but no luck still...!
Steve Chapman
thanks again paul for ur inputs...am now able to download file after using the following line in my code:request.Proxy = new WebProxy(myProxyServerIP);
Steve Chapman
no problem Steve
PaulB