问题描述
我有一个Windows窗体,用户可以通过该窗体选择他们要下载的多个文件。下载文件后,将对其进行进一步处理。我正在使用AsyncCompletedEventArgs
事件来跟踪每次下载的进度。
Public Function DownloadFileOnline(FileName As String)
Try
fileReader = New WebClient()
Dim Address As String
Address = getURL(FileName)
If (Not System.IO.Directory.Exists(Globals.LocalPath)) Then
System.IO.Directory.CreateDirectory(Globals.LocalPath)
End If
If Not (System.IO.File.Exists(Globals.LocalPath + FileName)) Then
AddHandler fileReader.DownloadFileCompleted,AddressOf download_complete
AddHandler fileReader.DownloadProgressChanged,AddressOf Download_ProgressChanged
fileReader.QueryString.Add("fileName",FileName)
fileReader.DownloadFileAsync(New Uri(Address),Globals.LocalPath + FileName)
End If
Catch ex As HttpListenerException
CSMessageBox.ShowError("Error accessing the Library",ex)
LogHelper.WriteLog("Error accessing the Library" + ex.Message,LogHelper.LogLevels.Error)
Catch ex As Exception
CSMessageBox.ShowError("Error accessing the Library",LogHelper.LogLevels.Error)
End Try
End Function
Private Sub download_complete(ByVal sender As Object,ByVal e As AsyncCompletedEventArgs)
RaiseEvent DownloadDone(sender,e)
RemoveHandler fileReader.DownloadFileCompleted,AddressOf download_complete
RemoveHandler fileReader.DownloadProgressChanged,AddressOf Download_ProgressChanged
End Sub
一旦下载了所有文件,我计划对所有文件一起执行一个功能。当所有选定文件下载完毕后,有什么方法可以引发事件吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)