我還有一個問題:(
我試圖下載多個文件我的應用程序C#Web客戶端下載多個文件
我的問題是:什麼做我必須做的檢查首先下載完成,然後繼續到第二下載等
這是我的代碼大氣壓:
private void DownloadBukkit()
{
MySingleton.Instance.FirstStartProgress = "Downloading Bukkit.jar... Please stand by...";
webClient.DownloadFileAsync(new Uri(MySingleton.Instance.BukkitDownloadLink), Jar_Location);
webClient.DownloadProgressChanged += backgroundWorker1_ProgressChanged;
webClient.DownloadFileCompleted += (webClient_DownloadFileCompleted);
}
private void DownloadDll()
{
if (!webClient.IsBusy)
{
MySingleton.Instance.FirstStartProgress = "Downloading HtmlAgilityPack.dll... Please stand by...";
webClient2.DownloadFileAsync(new Uri(Dll_HtmlAgilityPackUrl), Dll_HtmlAgilityPackLocation);
webClient2.DownloadProgressChanged += backgroundWorker1_ProgressChanged;
webClient2.DownloadFileCompleted += (webClient2_DownloadFileCompleted);
}
}
void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
DownloadDll();
}
void webClient2_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Invoke((MethodInvoker)
Close);
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Invoke((MethodInvoker)
delegate
{
labelProgress.Text = MySingleton.Instance.FirstStartProgress;
progressBar1.Value = e.ProgressPercentage;
});
}
我已經檢查此鏈接:DownloadFileAsync multiple files using webclient但我真的不知道如何植入這一:(。 (我是qu ite to new to C#)
Okai thx!那意味着我只需要在每個DownloadFileCompleted事件中放置一個新的webclient? 編輯:我試圖在DownloadfileCompleted事件中啓動第二次下載,但這似乎並沒有工作。 – 2012-04-02 14:53:58
@ Darkshadw我擴大了一點我的答案。我希望能夠說清楚。 – Icarus 2012-04-02 14:59:14
#Icarus每當我嘗試這樣做: 'WebClient webClient2 = new WebClient(); MySingleton.Instance.FirstStartProgress =「下載DLL ...請支持......」; webClient2.DownloadFileAsync(新Uri(Dll_HtmlAgilityPackUrl),Dll_HtmlAgilityPackLocation);' 它不想開始下載:(。 – 2012-04-02 15:10:28