Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.1k views
in .NET FTP by
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

1 Answer

0 votes
by (162k points)
Try changing to active mode.

Categories

...