Wie berechene ich die Download Geschwindigkeit?
Ich möchte die Geschwindigkeit eines Downloads berechnen der per Webclient.Downloadfileasync gestartet wird in KB/S und MB/S berechnen, wie stelle ich das an?
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 310625
Url: https://administrator.de/contentid/310625
Ausgedruckt am: 22.11.2024 um 16:11 Uhr
4 Kommentare
Neuester Kommentar
speed = data / interval
Did you miss the first math lessons in school ?
VB.Net example Form
Regards
Did you miss the first math lessons in school ?
VB.Net example Form
Imports System.Net
Public Class Form1
WithEvents client As WebClient
Dim currentBytes As Long = 0
Dim lastBytes As Long = 0
WithEvents tm As Timer
Private Sub btnDownload_Click(sender As Object, e As EventArgs) Handles btnDownload.Click
client = New WebClient
tm = New Timer()
With tm
.Interval = 500
.Start()
End With
client.DownloadFileAsync(New Uri("http://domain/download.iso"), Environ("Temp") & "\test.iso")
End Sub
Private Sub client_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles client.DownloadProgressChanged
pBar.Value = e.ProgressPercentage
currentBytes = e.BytesReceived
End Sub
Private Sub btnStopDownload_Click(sender As Object, e As EventArgs) Handles btnStopDownload.Click
client.CancelAsync()
tm.Stop()
End Sub
Private Sub tm_Tick(sender As Object, e As EventArgs) Handles tm.Tick
Dim speed As String
Dim lngDataPerInterval As Long = currentBytes - lastBytes
If lngDataPerInterval < (1024 * 1024) Then
speed = Math.Round((lngDataPerInterval / 1024) / (tm.Interval / 1000), 0) & " KB/s"
Else
speed = Math.Round((lngDataPerInterval / (1024 * 1024)) / (tm.Interval / 1000), 2) & " MB/s"
End If
lblStatus.Text = speed
lastBytes = currentBytes
End Sub
End Class
Zitat von @aqui:
I suppose, teached by Super Mario Did you miss the first math lessons in school
Indeed ! Missed completely what we call in the German Grundschule "das kleine Einmaleins" !
two fours love each other and get a baby 4....GREAT !!!
On top a stupid doublepost:
Webclient Download Größe in KB, MB etc. umrechnen
On top a stupid doublepost:
Webclient Download Größe in KB, MB etc. umrechnen