Exemplo n.º 1
0
        void Exited(object sender, EventArgs e)
        {
            BeginInvoke((Action)(() =>
            {
                int deleteCount = 0;
                while (File.Exists(_updateFileName) && deleteCount++ < 10)
                {
                    Thread.Sleep(3000);
                    try
                    {
                        File.Delete(_updateFileName);
                    }
                    catch (Exception)
                    {
                    }
                }

                Close();
                UpdateHelper.StartMainApp();
            }));
        }
Exemplo n.º 2
0
        void StartUpdateSetupApp(string fileName)
        {
            lbDownloadInfo.Text = "正在安装...";
            try
            {
                string  path    = new DirectoryInfo(Application.StartupPath).Parent.FullName;
                Process process = new Process();
                process.StartInfo           = new ProcessStartInfo(fileName, string.Concat("/S /D=", path));
                process.EnableRaisingEvents = true;
                process.Exited += Exited;
                process.Start();

                _updateInfoDal.Add(_updateInfo);
            }
            catch (Exception exception)
            {
                MessageBoxEx.Show(exception.Message, "运行更新程序安装包", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Close();
                UpdateHelper.StartMainApp();
            }
        }