Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4k views
in .NET FTP by (360 points)
Hi guys,

I'm having problems trying to syncronize a folder with the server. I have a combobox allowing to change the FTP connections properties (loading a .ftp file at runtime).

The problem apears when I try to re-run the folder synchronization more than once, either if the previous process was succesfully or if I cancel it, I'm receiving the message "Synchronize operation cancelled" the second time I want to run the BeginSynchronize newly.

Do you have any clue about this? How can I "reset" the ExFTPConnection for allowing me re-execute the synch process with no problems?

Many thanks in advance and best regards,

Julio

PS: I'm using edtFTPnet Express edition, and I need to synchronize two folders usinc asynchronize mode.

4 Answers

0 votes
by (162k points)
Please post a log file set to the Debug level, and a code snippet.
0 votes
by (360 points)
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
0 votes
by (162k points)
What version are you using?

One key problem seems to be that your directory listings aren't being successfully parsed.

This might be sorted out by upgrading to a later version if we know what you are using now.
0 votes
by (360 points)
Version is 3.7.0.0 (I think the latest one).

Anyway, I'm changing the approach now, so if a user is cancelling the update I won't allow him to re-run the update if they don't reload the form. This way is working 100 % of the times.

Many thanks & regards,

Julio

PD: I have no too much time right now to research, let's see in a couple of weeks.

Categories

...