コード例 #1
0
        private void DownloadFileProc()
        {
            bool b1 = HttpClass.DownloadFile(UpdateFileUrl, UpdateFileLocal, progressBar1);

            if (b1)
            {
                label1.Text = ("下载完毕");
                Process.Start(UpdateFileLocal);
                if (Directory.Exists(UpdateDataPath))
                {
                    Directory.Delete(UpdateDataPath, true);
                }
            }
            else
            {
                label1.Text        = ("下载失败");
                label1.ForeColor   = Color.Red;
                progressBar1.Value = 0;
            }
        }
コード例 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text    = "验证版本...";
            timer1.Enabled = false;
            bool b1 = HttpClass.DownloadFile(VersionFileUrl, VersionFileLocal, progressBar1);

            if (b1)
            {
                Text = string.Format("{0}/{1}", MainAppBuildVersion, UpdateAppBuildVersion);
                if (UpdateAppBuildVersion > MainAppBuildVersion)
                {
                    Form2 f2 = new Form2();
                    f2.edit1.Text = WhatsNew;
                    if (f2.ShowDialog() == DialogResult.OK)
                    {
                        label1.Text        = "下载文件...";
                        progressBar1.Value = 1;
                        Task downloadtask1 = new Task(new Action(DownloadFileProc));
                        downloadtask1.Start();
                    }
                    else
                    {
                        label1.Text        = "用户取消了操作";
                        progressBar1.Value = 0;
                    }
                }
                else
                {
                    label1.Text = "服务器上没有最新的版本";
                }
            }
            else
            {
                label1.Text        = ("版本验证失败");
                label1.ForeColor   = Color.Red;
                progressBar1.Value = 0;
            }
        }