我研究了很多,我找到了一种计算方法,但我不相信
请帮我解决它???:(
那是我的代码
while (sum < length)
{
stopWatch.Restart();
if (length - sum > packetSize)
{
count = fileStream.Read(buffer, 0, packetSize);
Send(socket_File, buffer);
}
else
{
buffer = new byte[length - sum];
count = fileStream.Read(buffer, 0, length - sum);
Send(socket_File, buffer);
}
stopWatch.Stop();
sum = sum + count;
SendFile.Downloaded = sum;
SendFile.Transfer_rate = ((sum * 8) / stopWatch.ElapsedMilliseconds).ToString();//kbps
}