Jack D
Jack D

Reputation: 1

Asynchronous ftp client (file download) in vb.net

I create an automatic ftp file downloader by using FTPwebrequest. In which, is there any possible to download multiple files simultaneously using Asynchrounous and threading concept? . I need to some guidance or tutorials for asynchrounous ftp file download. Pls guide me.

Upvotes: 0

Views: 1917

Answers (2)

Benjli
Benjli

Reputation: 125

You can download file asynchronously from the internet by that code, but I don't know if that works on ftp. Anyway, give it a try.

Dim client as new webclient
AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCallback 
client.downloadfileasync(New Uri("link"), _
                   path) 

Private Sub DownloadFileCallback(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs)
'What to do when the download was completed.
End sub

Hope the answer will help

Upvotes: 0

jjj
jjj

Reputation: 605

maybe this vb code could help:

' begin asynchronous transfer '
Dim asyncResult As IAsyncResult
asyncResult = ftp.BeginGetFile( _
    remotePath, _
    localPath, _
    New AsyncCallback(AddressOf MyCallback), _
    Nothing _
 )

Do 
    ' do something else here... '
Loop While Not asyncResult.IsCompleted

' get the result '
Dim bytes As Long 
bytes = ftp.EndGetFile(asyncResult)

code source

Upvotes: 1

Related Questions