我使用FTPwebrequest创建了一个自动ftp文件下载程序。其中,有没有可能使用Asynchrounous和线程概念同时下载多个文件? 。我需要一些指导或教程来进行asynchrounous ftp文件下载。请指导我。
答案 0 :(得分:1)
也许这个vb代码可以提供帮助:
' 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)
代码source
答案 1 :(得分:0)
您可以通过该代码从Internet异步下载文件,但我不知道它是否适用于ftp。无论如何,试一试。
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
希望答案有所帮助