I am using asp.net:
string host = "xx";
string user = "xx";
string password = "xx";
FTPClient ftp = null;
try
{
// set up client
Response.Write("Connecting</br>");
ftp = new FTPClient(host);
// login
Response.Write("Logging in</br>");
ftp.Login(user, password);
// set up passive ASCII transfers
Response.Write("Setting up passive, ASCII transfers</br>");
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;
// get directory and print to page
string[] files = ftp.Dir(".", true);
for (int i = 0; i < files.Length; i++)
Response.Write(files[i]);
// Shut down client
Response.Write("Quitting client");
ftp.Quit();
Response.Write("Test complete");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
The above code results in the following error:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
If I remove this code
// get directory and print to page
string[] files = ftp.Dir(".", true);
for (int i = 0; i < files.Length; i++)
Response.Write(files[i]);
It connects and closes ok.
Can anyone help?
Thanks
Danny