So I'm working on a download manager and I've implemented the pause/resume functionality as well. But in order to get the progress bar value when the download is resumed I need to get the existing length of the file before the download was stopped as well. Something like this.
private void updateProgressBar(DownloadProgressChangedEventArgs e)
{
if (InvokeRequired)
Invoke((MethodInvoker)delegate ()
{
updateProgressBar(e);
});
else
{
downloadProgressBar.Value = Convert.ToInt32((e.BytesReceived + existFileSize)/(e.TotalBytesToReceive + existFileSize)*100);
}
}
Where existFileSize is the size of the existing file after it was paused. But for some reason the progress bar only updates once the download is completed. But if i were to put lets say,
downloadProgressBar.Value = e.ProgressPercentage;
This instead of the previous line it works perfectly but does not give the result that i want.
Any help or advice would be appreciated.