so I'm using webClient.DownloadFileAsync(url, sFilePathToWriteFileTo);
to download a file
Url is string url = "http://localhost/1.zip";
sFilePathToWriteFileTo is root directory
Whenever I download the 500mb zip archive, my label1 goes berserk and says "Downloading with INF kb/s" and that's about when it starts not responding and crashes
label1 is label1.Text = string.Format("Downloading with {0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));
It works perfectly fine when I'm downloading low size files, 20mb-50mb
Oh btw, (I just re-read my post), sw is StopWatch, incase you wonder
What is the problem here, and how can I solve it?
-- Edit, added webClient:
using (webClient = new WebClient())
{
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(wzCompleted);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wzProgressChanged);
Uri url = new Uri(sUrlToReadFileFrom);
sw.Start();
try
{
webClient.DownloadFileAsync(url, sFilePathToWriteFileTo);
}
catch (Exception ex)
{
downloadInfo.Text = ex.Message;
}
}
wzProgressChanged:
private void wzProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
statusContent.Text = "Downloading new game files";
downloadInfo.Text = "Downloading: " + string.Format("{0} MB / {1} MB", (e.BytesReceived / 1024d / 1024d).ToString("0.00"), (e.TotalBytesToReceive / 1024d / 1024d).ToString("0.00")) + " with " + string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00")) + " (" + e.ProgressPercentage.ToString() + "%" + ")";
progressBar1.Value = e.ProgressPercentage;
}
wzCompleted: It's just enabling 2 buttons and disabling 2 others, no need for this?