WebClient.DownloadFileAsync - Download files one at a time

前端 未结 3 660
醉梦人生
醉梦人生 2020-12-05 16:42

I am using the code below to download multiple attachments from a TFS server:

foreach (Attachment a in wi.Attachments)
{    
    WebClient wc = new WebClient         


        
3条回答
  •  温柔的废话
    2020-12-05 17:21

    At the risk of sounding like an idiot, this worked for me:

    Console.WriteLine("Downloading...");
    client.DownloadFileAsync(new Uri(file.Value), filePath);
    while (client.IsBusy)
    {
        // run some stuff like checking download progress etc
    }
    Console.WriteLine("Done. {0}", filePath);
    

    Where client is an instance of a WebClient object.

提交回复
热议问题