Here you are the vb code:
Private Sub btUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btUpdate.Click
Enable_Controls(False)
Try
If Not Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Connect()
End If
Dim Rules As New EnterpriseDT.Net.Ftp.FTPSyncRules
Rules.DeleteIfSourceAbsent = True
Rules.IgnoreDate = True
Rules.IncludeSubdirectories = True
Rules.Direction = EnterpriseDT.Net.Ftp.TransferDirection.DOWNLOAD
Me.ExFTPConnection1.BeginSynchronize(Rules, Nothing, Nothing)
Catch ex As Exception
MsgBox(ex.Message)
Try
Enable_Controls(True)
If Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Close()
End If
Catch ex2 As Exception
'MsgBox(ex2.Message)
End Try
End Try
End Sub
Private Sub btCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btCancel.Click
If Me.ExFTPConnection1.IsConnected Then
Dim response As Object
response = MsgBox("Data update process is still running. Do you want to abort data update?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question)
If response = vbYes Then
Me.btCancel.Enabled = False
Try
If Me.ExFTPConnection1.IsTransferring Then
Me.ExFTPConnection1.CancelTransfer()
If Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Close()
End If
Me.txtStatusHint.Text = "Update has been canceled by the user."
Enable_Controls(True)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Else
MsgBox("FTP server is not connected already. Please try it again in a few seconds.", MsgBoxStyle.Information)
End If
End Sub
Private Sub ExFTPConnection1_Error(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPErrorEventArgs) Handles ExFTPConnection1.Error
Try
If Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Close()
End If
Me.txtStatusHint.Text = "Update has been canceled by the user."
Enable_Controls(True)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ExFTPConnection1_Synchronized(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPSyncEventArgs) Handles ExFTPConnection1.Synchronized
If Not e.Cancel Then
If e.Succeeded Then
' Here I have removed a piece of code that has nothing to do with the problem
Enable_Controls(True)
Else
Enable_Controls(True)
If Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Close()
End If
MsgBox(e.Exception.Message)
End If
Else 'CANCELLED BY THE USER
If Me.ExFTPConnection1.IsConnected Then
Me.ExFTPConnection1.Close()
End If
Me.txtStatusHint.Text = "Update has been canceled by the user."
Enable_Controls(True)
End If
End Sub
Where Enable_Controls(True) is just a procedure to enable or disable controls. It seems that ExFTPConnection1_Synchronized sub is called the second time without doing any attempt to synchronize. Why is this event fired in a wrong time the second time?
And now the LOG file (private info has been removed manually):
INFO [LicenseProperties] 22 May 2009 12:41:17.109 : Licence expiry date: 31/12/9999
INFO [LicenseProperties] 22 May 2009 12:41:17.109 : Production license
INFO [LicenseProperties] 22 May 2009 12:41:17.125 : Licence expiry date: 31/12/9999
INFO [LicenseProperties] 22 May 2009 12:41:17.125 : Production license
DEBUG [ExFTPClient] 22 May 2009 12:41:17.125 : Connecting to
DEBUG [HostNameResolver] 22 May 2009 12:41:17.125 :
DEBUG [ExFTPControlSocket] 22 May 2009 12:41:17.125 : Connecting directly to ftp-server
DEBUG [FTPControlSocket] 22 May 2009 12:41:17.312 : Setting socket timeout=120000
DEBUG [FTPControlSocket] 22 May 2009 12:41:17.312 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 22 May 2009 12:41:17.312 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=, controlPort=21, timeout=120000
DEBUG [FTPControlSocket] 22 May 2009 12:41:17.312 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 22 May 2009 12:41:17.484 : 220-Microsoft FTP Service
DEBUG [FTPControlSocket] 22 May 2009 12:41:17.859 : 220 IIS411
DEBUG [FTPConnection] 22 May 2009 12:41:17.859 : Connected to
DEBUG [FTPControlSocket] 22 May