I'm testing the connection to an FTP server from my c# .NET application which is working. If a connection can be made or the server address is invalid then the response is instant. However, it is very slow if the credentials are valid but no connection can be made. How can I reduce the timeout time on this?
FTP test code:
try
{
FtpWebRequest ftpRequest =
(FtpWebRequest)WebRequest.Create(new Uri("ftp://"+ftpServer+"/"));
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpRequest.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
ftpRequest.GetResponse();
MessageBox.Show("OK");
}
catch (Exception ex)
{
MessageBox.Show("Error");
}
Thanks