0
我试图让与vb.net失败一个ftp流的上传速度的FTP上传速度...获取与vb.net
我不知道如果数学都OK,我用Google搜索一会儿试图找到上传的方程,我发现它在一些代码示例,但下载...
这里是我的代码:
Dim chunksize As Integer = 2048
Dim offset As Long = 0
Dim readBytes As Long = 0
Dim startTime As DateTime
Dim endTime As DateTime
While offset < buffer.Length
readBytes = fileStream.Read(buffer, 0, chunksize)
requestStream.Write(buffer, 0, readBytes)
offset += readBytes
endTime = DateTime.Now
Dim duration = endTime - startTime
Dim inASec As Double = 1000/duration.Milliseconds
startTime = DateTime.Now
RaiseEvent FileSpeed(Math.Round((64 * inASec)/8, 2).ToString)
RaiseEvent FileProgress(offset, buffer.Length)
End While
非常感谢,正确的数学是Math.Round((偏移/ 1024)/持续时间,2)的ToString得到kbps的。 – 2012-02-12 00:32:17