+1 vote
by (570 points)
edited

Hi I'm using Rebex.Net.Ftp 2.0.2567, and I want to check the Ftp connection state at the end of my try/catch block in order to disconnect if there was some error during transfer etc. I thought something like this might work :

Finally

    If ftp.GetConnectionState.Connected Then
        UpdateStatus("Disconnecting")
        ftp.Disconnect()
    End If

End Try

However, I get a InvalidOperationException error telling me that I'm "Not connected to the server".

Can anyone suggest where I'm going wrong please ?

Thanks, Martin

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (148k points)
edited

This is caused by a bug in the Ftp object's GetConnectionState method that was fixed in Rebex FTP 2.3.2666: GetConnectionState no longer fails on disconnected objects. Sorry for inconvenience!

Workaround for 2.0.2567:

   Finally

       If ftp.State <> FtpState.Disconnected _
          AndAlso ftp.GetConnectionState.Connected Then
            UpdateStatus("Disconnecting")
            ftp.Disconnect()
       End If

   End Try
by (570 points)
Thanks ! I'll try the workaround
...