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 concep开发者_运维知识库t? . I need to some guidance or tutorials for asynchrounous ftp file download. Pls guide me.
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
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
精彩评论