我们有一个自定义组件批量下载文件,但我似乎无法报告各个文件的进度。
我能够获取由事件处理程序反馈处理的启动文件传输消息,但由于下载文件一次可以下载30个左右的文件,它显然不会显示下一条消息,所以我的问题我如何通过某些描述的状态栏报告每个文件的进度。
Event FeedBack(ByVal message As String, ByVal displayToUser As Boolean)
Friend Function DownloadFilesFromFTPsite(ByVal filename() As String) As Boolean
Dim retVal As Boolean = False
Dim ftpController As New FTP.DotNet.FtpClient(cfb.FTPHost, cfb.FtpUserName, cfb.FtpPassword)
WriteToLogAndRaiseFeedback("Starting File Transfer", True)
Dim ftpResponse() As FTP.DotNet.infoFTPresponse
ftpResponse = ftpController.DownloadFiles(IIf(cfb.SourceFolder.Trim = "", "/", cfb.SourceFolder), filename, cfb.TargetFolder)
WriteToLogAndRaiseFeedback("Transfering File " + filename.ToString(), True)
If Not IsNothing(ftpResponse) AndAlso ftpResponse.Length > 0 Then
For Each thisResponse As FTP.DotNet.infoFTPresponse In ftpResponse
If Not IsNothing(thisResponse) _
AndAlso IsNumeric(thisResponse.statusCode) AndAlso thisResponse.statusCode = 226 Then
'226 = success
WriteToLogAndRaiseFeedback("...document downloaded sucessfully", True)
retVal = True
ElseIf Not IsNothing(thisResponse) Then
WriteToLogAndRaiseFeedback("...FAILED to download document: " & thisResponse.statusDescription, True)
retVal = False
Exit For
End If
Next
End If
Return retVal
End Function