Answer the question
In order to leave comments, you need to log in
How to download multiple files through WebClient one by one? Via DownloadFileAsync?
Goodnight. Faced the problem of downloading several files one after another.
Full code how to download:
void DownloadMPQ(Uri u, string s)
{
WebClient web = new WebClient();
web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Download);
web.DownloadFileCompleted += new AsyncCompletedEventHandler(DownComp);
web.DownloadFileAsync(u, s);
}
void DownComp(object sender, AsyncCompletedEventArgs e)
{
NotificShow(String.Format("'{0}' скачан.", ThisFile));
}
void Download(object sender, DownloadProgressChangedEventArgs e)
{
long q = e.TotalBytesToReceive / 1024;
prgDownload.Properties.Maximum = (int)q;
prgDownload.EditValue = e.BytesReceived / 1024;
}
DownloadMPQ(new Uri("http://localhost/mp.mpq"), "mp.mpq");
Answer the question
In order to leave comments, you need to log in
1) immediately try DownloadFileTaskAsync , it is easier to work with tasks;
2) wait for the task to download one file to complete before starting the next one;
3)
New stream? Tried. The progress bar does not move.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question