I am trying to use WebClient to download a .zip file from my server. In debugging mode the code works perfectly, but when I deploy my software the file does not even begin to download.
After my program checks to see if an update is available, it should download the .zip file from my web server via the following code:
Imports System
Imports System.Net
Imports System.Net.WebClient
Public WithEvents fileDownloader As Net.WebClient
Public gstrTempPath As String = ""
Private Sub FileDownload_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim gstrTempPath As String = Application.StartupPath & "\Temp"
If Not Directory.Exists(gstrTempPath) Then Directory.CreateDirectory(gstrTempPath)
InitiateDownload("http://www.mydomain.com/SETUP.zip", Application.StartupPath & "\Temp\SETUP.zip")
End Sub
Private Sub InitiateDownload(ByVal remoteUrl As String, ByVal localFilePath As String)
'Reset the progress indicators.
Me.PercentLabel.Text = (0).ToString("p0")
Me.ProgressBar1.Value = 0
If Me.fileDownloader Is Nothing Then
'This is the first download so create the web client.
Me.fileDownloader = New Net.WebClient
End If
'Start downloading the file in the background.
Me.fileDownloader.DownloadFileAsync(New Uri(remoteUrl), localFilePath)
End Sub
Any help would be greatly appreciated as to why this file downloads perfectly when in debugging mode, but not when I deploy my program as a final copy. Perhaps I am missing a required .dll???