JagoVB
20th November 2011, 09:33 AM
gan ane kan lagi rencanain buat browser yang ada download managernya... nah ane udah buat download managernya dan bisa download... masalahnya, downloadnya ga bisa di pause... ane mau tanya, code untuk pause download kayak apa gan :tanya:
oh ya nih gan codingan ane
Spoiler for code:
Code:
Imports System.Net
Public Class Form1
Public WithEvents dl As New WebClient
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
With SaveFileDialog1
.InitialDirectory = System.Reflection.Assembly.GetExecutingAssembly.Lo cation
.Filter = "All File (*.*)|*.*"
.FilterIndex = 1
.RestoreDirectory = True
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
txtSave.Text = SaveFileDialog1.FileName
End If
End With
End Sub
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
On Error GoTo err
dl.DownloadFileAsync(New Uri(txtUrl.Text), txtSave.Text)
Exit Sub
Err:
MsgBox("There was an error while downloading the file: " & _
Err.Description, MsgBoxStyle.Critical, _
"FATAL ERROR!")
End Sub
Private Sub dl_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles dl.DownloadProgressChanged
PB.Value = e.ProgressPercentage
lblSize.Text = Int(e.BytesReceived / 1024) & " kB" & " / " & Int(e.TotalBytesToReceive / 1024) & " kB"
lblper.Text = e.ProgressPercentage & "%"
End Sub
End Class
bantuin ya gan :shakehand:
oh ya sama code untuk ngetahui speed downloadnya juga ya gan :D
</div>
oh ya nih gan codingan ane
Spoiler for code:
Code:
Imports System.Net
Public Class Form1
Public WithEvents dl As New WebClient
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
With SaveFileDialog1
.InitialDirectory = System.Reflection.Assembly.GetExecutingAssembly.Lo cation
.Filter = "All File (*.*)|*.*"
.FilterIndex = 1
.RestoreDirectory = True
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
txtSave.Text = SaveFileDialog1.FileName
End If
End With
End Sub
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
On Error GoTo err
dl.DownloadFileAsync(New Uri(txtUrl.Text), txtSave.Text)
Exit Sub
Err:
MsgBox("There was an error while downloading the file: " & _
Err.Description, MsgBoxStyle.Critical, _
"FATAL ERROR!")
End Sub
Private Sub dl_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles dl.DownloadProgressChanged
PB.Value = e.ProgressPercentage
lblSize.Text = Int(e.BytesReceived / 1024) & " kB" & " / " & Int(e.TotalBytesToReceive / 1024) & " kB"
lblper.Text = e.ProgressPercentage & "%"
End Sub
End Class
bantuin ya gan :shakehand:
oh ya sama code untuk ngetahui speed downloadnya juga ya gan :D
</div>