Hello I have this code
That works Fine but I need to change
To
I keep getting errors and i cant seem to fix it can you help and btw the code download a item and tells you the percent and the size it has download sorry for the bad spelling i am only 15
VB.NET:
Public Class Frm_Download1
Private myURL As String = "http://www.cpgames.co.uk/test.zip"
Private myFile As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & myURL.Substring(myURL.LastIndexOf("/"))
Private WithEvents myWebClient As New Net.WebClient()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myWebClient = New Net.WebClient
ProgressBar1.Value = 0
Label1.Text = "Downloading..."
myWebClient.DownloadFileAsync(New Uri(myURL), myFile)
End Sub
Private Sub myWebClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles myWebClient.DownloadFileCompleted
If ProgressBar1.Value = ProgressBar1.Maximum Then
MsgBox("Download Completed", MsgBoxStyle.Information)
Else
IO.File.Delete(myFile)
End If
End Sub
Public Sub myWebClient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles myWebClient.DownloadProgressChanged
Try
Dim dDownloadProgress As Decimal = CStr(e.BytesReceived / e.TotalBytesToReceive * 100)
ProgressBar1.Value = CInt(dDownloadProgress)
Dim dDownloadedMB As Decimal = Format((e.BytesReceived / 1024) / 1024, "###,###,##0.00")
Dim dTotalToDownloadMB As Decimal = Format((e.TotalBytesToReceive / 1024) / 1024, "###,###,##0.00")
Label1.Text = "Downloaded: " & dDownloadedMB & "MB out of " & dTotalToDownloadMB & "MB - Progress: " _
& Format(dDownloadProgress, "###.00") & "%"
Catch ex As Exception
End Try
End Sub
End Class
That works Fine but I need to change
VB.NET:
http://www.cpgames.co.uk/test.zip
To
VB.NET:
textbox1.text
I keep getting errors and i cant seem to fix it can you help and btw the code download a item and tells you the percent and the size it has download sorry for the bad spelling i am only 15