I used the sample code from the tutorial and I can't connect.
This is the code I am using:
Ftp ftp = new Ftp();
ftp.CommandSent += new FtpCommandSentEventHandler(ftp_CommandSent);
ftp.ResponseRead += new FtpResponseReadEventHandler(ftp_ResponseRead);
try
{
TlsParameters par = new TlsParameters();
par.CertificateVerifier = CertificateVerifier.AcceptAll;
//ftp.Connect(hostname, 21, par, FtpSecurity.Explicit);
ftp.Connect(hostname, 21, null, FtpSecurity.Explicit);
ftp.Login(username, password);
ftp.ChangeDirectory(dirChange);
long bytes;
if (method == "get")
{
bytes = ftp.GetFile(remoteFile, localFile);
}
else if (method == "put")
{
bytes = ftp.PutFile(localFile, remoteFile);
}
else
{
return;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
ftp.Disconnect();
ftp.Dispose();
}
The error I get is:
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.
I know this is a timeout error but I'm not sure what else to try.
When I change directories I see username.directory as the current directory. I assume that is correct. The last response I see is "Entering pasive mode".