Hi Alain
Thanks for you reply. I tried it and it works. Before we close this issue, I would like to confirm something with you. I forgot to mention that I would also like to differentiate between a situation when the user enter wrong credentials. So to summarize, i need a sure, robust way (not relying on FTP reply code) to tell btwn these:
1) server/network down
2) wrong credentials
3) file/(s) not found at the specified location.
Looking at the code you provided in your last reply, i saw that FileSystemException was being thrown in the code below, whether user entered wrong credentials or server down.
try
{
rootFolder = new FtpFolder(connection);
// This will force the connection to the Ftp server. If
// it fails, this means the host is not reachable.
bool rootExists = rootFolder.Exists;
}
catch ( Exception ex)
{
Console.WriteLine("Unable to connect to server " + ex.GetType().ToString() );
return;
}
To solve this, i used TestConnection() function. After initial testing it turned out that I can indeed use this function as it throws different exceptions depending on the case:
1) server/network down - FtpIOException or FtpInternalException
2) wrong credentials - FtpReplyException
i can deal with case 3) using the code you provided.
If all of this works the way I think it does, then I am covered. Please confirm.