FTPWebRequest always timeouts

G

Guest

I am running the following code (using VS 2005) with the appropriate
username and password and the request always timeouts:

FtpWebRequest request =
(FtpWebRequest)WebRequest.Create("ftp://integration300:20/");
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.UsePassive = false;
request.Credentials = new
NetworkCredential(<user>,<password>);
request.Proxy = null;

FtpWebResponse response =
(FtpWebResponse)request.GetResponse();
response.Close();

If I perform the query "ftp://integration300" in IE then I can see all the
available drives as expected. I can also access the drives by calling "ftp
integration300" at a command prompt and typing in the user name and password.

Does anyone know why the query may be timing out?
 
G

Guest

ftp://integration300 uses the default port (21) but your code is attempting
to use port 20. Apparently there is nothing listening to port 20, so there
you go.
Pete
 
G

Guest

Sorry - the code should have read:

FtpWebRequest request =
(FtpWebRequest)WebRequest.Create("ftp://192.168.80.114:21/");
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.UsePassive = false;
request.Credentials = new NetworkCredential("guest",null);
request.Proxy = null;

FtpWebResponse response =
(FtpWebResponse)request.GetResponse();
response.Close();

and I still get the same problem. I was trying all sorts of things out and
forgot to set the port number back to 21
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top