I am trying to download a file in my application.. If I call it from a button or menu click event it works but in other callings it does not and returns a 0 length file and never attempts to download the file..
This above works perfect and 100% of the time it downloads the file correctly and shows progress and completion status.
This above does not work. It returns a zero length file and never attempts to download the file as soon as it starts it exits the routine and there is no progress or completion status and no errors.
Calling the working routine like above does not work either the routine returns the same zero length file and actions as above..
If I put the routine in a form by itself and call it in the load routine it works correctly..
I'm puzzled..
TIA
Rick
Code:
Private Sub ClickMenu_Click(sender As Object, e As EventArgs) Handles ClickMenu.Click
Dim client As New WebClient()
AddHandler client.DownloadProgressChanged, AddressOf ShowDownloadProgress
AddHandler client.DownloadFileCompleted, AddressOf OnDownloadComplete
client.DownloadFileAsync(New Uri("http://www.n2amg.com/files/L32LookupsUpdate.zip"), AppPath & "\Update\L32LookupsUpdate.zip")
End Sub
Code:
Private Sub Download()
Dim client As New WebClient()
AddHandler client.DownloadProgressChanged, AddressOf ShowDownloadProgress
AddHandler client.DownloadFileCompleted, AddressOf OnDownloadComplete
client.DownloadFileAsync(New Uri("http://www.n2amg.com/files/L32LookupsUpdate.zip"), AppPath & "\Update\L32LookupsUpdate.zip")
End Sub
Code:
ClickMenu_Click(ClickMenu, New System.EventArgs)
If I put the routine in a form by itself and call it in the load routine it works correctly..
I'm puzzled..
TIA
Rick