private void Downloader(string file_url,string saving_path)
{
using (WebClient wClient = new WebClient())
{
label2.Text = "Скачивание...";
Uri url = new Uri(file_url);
wClient.DownloadFileAsync(url, saving_path);
wClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
wClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
}
}
Скорость загрузки файла!
Загрузку выполняю с помощью
Код:
public void DownLoad(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Specify that the DownloadFileCallback method gets called
// when the download completes.
client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
// Specify a progress notification handler.
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
client.DownloadFileAsync(uri, @"c:\tmp.zip");
}
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Specify that the DownloadFileCallback method gets called
// when the download completes.
client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
// Specify a progress notification handler.
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
client.DownloadFileAsync(uri, @"c:\tmp.zip");
}
и метод для вывода данных
Код:
public void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
dl_progress.Value = e.ProgressPercentage;
textBox3.Text=(((string)e.UserState + " downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive + " bytes. " + e.ProgressPercentage + " % complete..."));
}
{
// Displays the operation identifier, and the transfer progress.
dl_progress.Value = e.ProgressPercentage;
textBox3.Text=(((string)e.UserState + " downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive + " bytes. " + e.ProgressPercentage + " % complete..."));
}
Сижу думаю как корректней выводить скорость...
Давайте помогайте!!!