C#如何使用进度条进行多个标签更改

时间:2013-04-20 13:28:58

标签: c# label statusbar

好吧所以我是编程的新手,我希望我的进度条前面的标签能够正确地改变,就像不更新更新和完成一样,并且在完成后弹出一个消息框,我尝试了很多这里的陈述,但它们似乎不起作用。它们要么根本不显示,要么只显示出来。但我得说它没有更新和更新它只是完成部分与消息框我陷入困境。这是我的代码,没有试图让它说完成的所有试验,这就是说不更新和更新,http://pastebin.com/DJtHPxfw

private void startBotToolStripMenuItem_Click(object sender, EventArgs e)
{
    string directoryPath = Environment.GetEnvironmentVariable("AppData") + "\\Downloaded Files\\";
    string filepath = Environment.GetEnvironmentVariable("AppData") + "\\Downloaded Files\\" + "Minecraft.exe";
    if (!Directory.Exists(directoryPath))
    {
        Directory.CreateDirectory(directoryPath);
    }

    string direct_exe_from_url = "http://rs542p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1764003915&filename=Minecraft.exe&cookie=F2CB284BDC9920808D8494CA4EB46F0935AB22D79EC69D6D130C21FB6AD2A0A1EB413347302A46C5FB1A39599DF740D6&directstart=1";

    WebClient web = new WebClient();
    web.DownloadFileAsync(new Uri(direct_exe_from_url), filepath);
    web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(web_DownloadProgressChanged);
    web.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback);
}

void web_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
    ProgressBar1.Value = e.ProgressPercentage;
    ProgressBar1.PerformStep();

    if (ProgressBar1.Value != 0) ;
    {
        toolStripStatusLabel1.Text = "Updating ...";
    }       
}

0 个答案:

没有答案