Calculate estimate of remaining download time
<p>Here is my estimate time code. It is working but there is a mistake in the time. </p>

<pre><code>if ((DateTime.Now - _startDate).Seconds &gt; 0)
{
    kbPerSecond = (int)((100 * 1000) / 8);
}
long sent = (TotalBytes - BytesRead);
long remainingseconds = sent / kbPerSecond;
string remainingTimeDisplay = string.Empty;
if (remainingseconds &gt; 0)
{
    if (remainingseconds &gt; 60)
    {
        if (remainingseconds &gt; 3600)
        {
            remainingTimeDisplay += ((int)(remainingseconds) / 3600).ToString("n0") + " Hours, ";
            remainingseconds %= 3600;
        }
        remainingTimeDisplay += (((int)remainingseconds) / 60).ToString("n0") + " Minutes,  ";
        remainingseconds %= 60;
    }
    remainingTimeDisplay += ((int)remainingseconds).ToString("n0") + " Seconds remaining";
    lbl_estimate.Text = remainingTimeDisplay;
}
</code></pre>

<p>The problem lies in that after the download completes, the estimated time will be displayed as '1 sec remaining' instead of zero.</p>

<p>What am I doing wrong?</p>
