Ola,
I'm downloading 5 files async. The downloaded files are replacing important files which are needed to load my app. and the executable itself. The problem is that I don't know when the last file is downloaded.
vb.net Code:
wclient1.DownloadFileAsync(New Uri(webFolder & fName1), Application.StartupPath & "\" & fName1) wclient2.DownloadFileAsync(New Uri(webFolder & fName2), Application.StartupPath & "\" & fName2) wclient3.DownloadFileAsync(New Uri(webFolder & fName3), Application.StartupPath & "\" & fName3) wclient4.DownloadFileAsync(New Uri(webFolder & fName4), Application.StartupPath & "\" & fName4) wclient5.DownloadFileAsync(New Uri(webFolder & fName5), Application.StartupPath & "\" & fName5) Private Sub wClient1_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles wclient1.DownloadProgressChanged Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString()) Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString()) Dim percentage As Double = bytesIn / totalBytes * 100 download_progress.Value = Int32.Parse(Math.Truncate(percentage).ToString()) wclient1.Dispose() End Sub Private Sub wClient2_..... '...etc
What I did was
...which is wrong, 'cause I don't know which file is downloaded last.vb.net Code:
Private Sub wclient5_DownloadFileCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Handles wclient5.DownloadFileCompleted System.Diagnostics.Process.Start(Application.StartupPath & "\my.exe") wclient5.Dispose() Application.Exit() End Sub
Anyone knows how to solve this? Thanks in advance.





Reply With Quote