Finding whether the server allows passive or active mode is a bit tricky.
To detect whether passive mode is possible, we have to improvise a bit. One possible way to do this with Rebex FTP:
- Make sure passive mode is enabled
- Lower the timeout from the default value of 60 seconds to something like
5 (or even leave it at 60 if detection speed is not an issue for you)
- Initiate a TransferProgress event handler
- Try calling
GetList
or GetNameList
(preferably on a folder with few
files)
4.
- If the event handler is called at least once with state of
FtpTransferState.Downloading
, consider passive mode possible
- If you get an
FtpException
with the Status
set to Timeout
, consider passive mode not impossible
- If you get an
FtpException
with the Status
set to ConnectFailure
, consider passive mode not impossible
- If you get other result, another error occured
Anyway, this seems rather complicated, so I added it into our list of possible future enhancements.
Vote the question up if it's important to you.