For a Disconnected event to really be usable, it would also have to be raised on connection failures, and the only way to reliably detect that is to periodically send a small chunk of data over the connection while idle. That's an action we would rather not be doing automatically, so we decided against adding the Disconnected event.
Instead, the recommended way to detect disconnection (including connection failure) is to periodically call FileTransferClient
's KeepAlive()
method while idle - if it fails, it means the connection has been disconnected or failed. To find out more about the failure reason, check the contents of NetworkSessionException
(FtpException
for FTP protocol, SftpException
for SFTP protocol).