// 检查并下载新版本。
        private bool checkDownloadVersionFiles()
        {
            VersionDownloadHelper download = new VersionDownloadHelper();
            double newNumber = 0;
            bool   exists    = download.CheckExistsNewVersion(out newNumber);

            if (exists)
            {
                bool b = download.DownloadVersionFileDialog();

                if (b)
                {
#if (!DEBUG)
                    //startNewApplication(_ApplicationName, string.Empty);
                    //如果成功下载,需要启动Copy 新版本的功能
                    string lastVersionLog = string.Format(DOWNLOAD_LOG, newNumber);
                    string val            = MB.Util.IniFile.ReadString("VersionUpdate", "DownLoad", string.Empty, lastVersionLog);
                    //判断版本是否已经下载
                    if (string.Compare(val, "True", true) == 0)
                    {
                        completedNewVersionUpdate(newNumber);
                    }
#else
                    MB.Util.IniFile.WriteString("VersionInformation", VERSION_NUMBER_CFG_KEY, newNumber.ToString(), APPLICATION_INFO);
#endif
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 判断是否存在已经下载完成但未更新的版本,如果存在就更新它。
        /// </summary>
        /// <returns></returns>
        public bool CheckAndUpdateNewVersion()
        {
            try {
                // MB.Util.TraceEx.Write("52");
                if (!System.IO.Directory.Exists(AUTO_UPDATE_PATH))
                {
                    return(checkDownloadVersionFiles());
                }

                string[] versions = System.IO.Directory.GetDirectories(AUTO_UPDATE_PATH);
                if (versions == null || versions.Length == 0)
                {
                    return(checkDownloadVersionFiles());
                }
                // MB.Util.TraceEx.Write("60");
                double        clientVersion = GetClientVersionNumber();
                List <string> lst           = new List <string>(versions);
                lst.Sort();
                string active = lst.Last();

                string pathName = System.IO.Path.GetFileName(active);

                string[] v = pathName.Split(' ');

                double lastVersion = System.Convert.ToDouble(v[1]);
                //如果当前应用程序的版本号大于或者等于已下载或者已完成下载的版本,那么就判断并下载是否存在的新版本
                VersionDownloadHelper download = new VersionDownloadHelper();
                double serverNewNumber         = 0;
                bool   exists = download.CheckExistsNewVersion(out serverNewNumber);

                if (clientVersion >= lastVersion || lastVersion < serverNewNumber)
                {
                    return(checkDownloadVersionFiles());
                }
                // MB.Util.TraceEx.Write("76");
                string lastVersionLog = string.Format(DOWNLOAD_LOG, lastVersion);
                string val            = MB.Util.IniFile.ReadString("VersionUpdate", "DownLoad", string.Empty, lastVersionLog);
                //判断版本是否已经下载
                if (string.Compare(val, "True", true) == 0)
                {
                    //  MB.Util.TraceEx.Write("81");
                    completedNewVersionUpdate(lastVersion);
                }
                else
                {
                    //  MB.Util.TraceEx.Write("85");
                    //存在未完成的版本。
                    return(checkDownloadVersionFiles());
                }
            }
            catch (Exception ex) {
                throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, string.Empty);
            }
            //最后表示不存在新版本
            return(false);
        }