VB Code:
Public Sub DownloadFile(ByVal fileUrl As String, ByVal saveTo As String, ByVal progress As ProgressBar)
Dim client As New WebClient
Dim myStream As Stream = client.OpenRead(fileUrl)
progress.Visible = True
progress.Maximum = CType(myStream.Length, Integer)
'Dim sr As New StreamReader(myStream)
Dim r As New BinaryReader(myStream)
Dim fs As New FileStream(saveTo, FileMode.Create)
Dim w As New BinaryWriter(fs)
Dim i As Long, res As Byte, locate As Integer = 0
For i = 0 To myStream.Length
res = r.ReadByte()
w.Write(res)
progress.Value += 1
Next i
progress.Visible = False
progress.Value = 0
w.Close()
fs.Close()
r.Close()
End Sub