-4
我已經使用C#和Microsoft API編寫了一個程序,顯示您的下載量,但它並未告訴我下載的正確大小,例如:如果我下載了10 MB文件,該程序顯示11 MB已下載。
我也在網絡狀態窗口中檢查,仍然告訴我,就像我的程序。
爲什麼? ISP中的其他軟件的工作方式與我擁有的相同嗎?下載的大小超過了真實
objIPInterfaceStatistics2 = objNetworkInterface[numberinterface].GetIPStatistics();
long newBytesreceived;
newBytesreceived = objIPInterfaceStatistics2.BytesReceived;
if (checkdata == true)
{
checkdata = false;
newBytesreceived = 0;
}
long newUsage = newBytesreceived - oldBytesreceived2;
trafficusage += newUsage;
float converttrafficusage = trafficusage/1000000;
oldBytesreceived2 = objIPInterfaceStatistics2.BytesReceived;
worker.ReportProgress((int)Math.Ceiling(converttrafficusage));
Thread.Sleep(1000);
難道我們只是爲了想象一下你寫的代碼執行和如何/如果你已經有了有問題?請嘗試創建某種類型的[mcve],如果您需要幫助來確定您做錯了什麼。 –
您需要考慮網絡開銷 – ChrisBint
您確定他們使用的是「度量」嗎?他們可能會向你展示MibiBytes上的大小而不是MegaBytes – arracso