Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.1k views
in .NET FTP by (1.5k points)
Hi
I'm after a bit of advice.
Using VB.net, I'm trying to get the server's current filecount from within the Downloaded event. In the sample code, its not returning from .GetFiles.

Private Sub SecureFTPConnection1_Downloaded(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs) Handles SecureFTPConnection1.Downloaded
Try
Dim files As String() = ftpConnection.GetFiles()
Dim iCount As Integer = 0
If UBound(files) > 0 Then
iCount = UBound(files)
End If


Obviously .GetFiles can't be called from with .Downloaded. Might this need a delegate or something?
Can someone point me in the right direction please?

cheers
Malcom

3 Answers

0 votes
by (51.6k points)
Try setting UseGuiThreadIfAvailable to false, which will cause all event-handlers to be called on whichever thread is invoking the methods on FTPConnection. If that doesn't work then you will need to use a delegate and the Control.BeginInvoke method.

- Hans (EnterpriseDT)
0 votes
by (1.5k points)
Thanks Hans but no luck .
If I set UseGuiThreadIfAvailable to false then I have no EDT Gui and can't see whats going on with EDTFTP.

Back to delegate research then

cheers
malcom
0 votes
by (1.5k points)
Hi again

Ok, I've had a play with delegates but this is an area where I have little knowledge. I wonder if anyone can help me?
Without the delegate, the line 'ftpConnection.GetFiles()' in function getRemoteFtpFiles() never completes.
Using the delagate, it still fails top complete that line.

Really appreciate any expert ideas here.

In my declarations I have this -
     Public Delegate Sub getRemoteFtpFilesRaw()



I have a SecureFTPConnection1.Downloaded event with this -
    Private Sub SecureFTPConnection1_Downloaded(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs) Handles SecureFTPConnection1.Downloaded
        Dim getRemoteFtpFilesDelegate As getRemoteFtpFilesRaw
        getRemoteFtpFilesDelegate = AddressOf getRemoteFtpFiles
        getRemoteFtpFilesDelegate.Invoke()


  Private Function getRemoteFtpFiles() As Integer
        Try
            Dim files As String() = ftpConnection.GetFiles()
            Dim iCount As Integer = 0
            If UBound(files) > 0 Then
                iCount = UBound(files)
            End If
            Return iCount
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function





cheers
Malcom

Categories

...