Exemplo n.º 1
0
        /// <summary>
        /// 检查更新
        /// </summary>
        /// <returns></returns>
        private bool CheckUpdateApp()
        {
            try
            {
                Int32  dwFlag         = new Int32();
                string autoUpdatePath = Application.StartupPath + @"\ComputerExam.Update.exe";

                if (!InternetGetConnectedState(ref dwFlag, 0))
                {
                    return(false);
                }
                if (!PublicClass.CheckForUpdate())
                {
                    return(false);
                }
                if (!File.Exists(autoUpdatePath))
                {
                    return(false);
                }

                Process.Start(autoUpdatePath);
                Environment.Exit(0);
            }
            catch (WebException)
            {
                LogHelper.WriteLog(typeof(frmLogin), "当前更新服务不可用,请联系管理员。");
                return(false);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(frmLogin), ex);
                return(false);
            }

            return(true);
        }