Ejemplo n.º 1
0
        private void UpdateForm_Load(object sender, EventArgs e)
        {
            string file = Application.StartupPath + Path.DirectorySeparatorChar + "version.ini";

            if (File.Exists(file))
            {
                Ini ini = new Ini(file);
                app = new AutoVersionInfo();

                app.SoftName    = ini.Read("version", "name", 256);
                app.Version     = ini.Read("version", "version", 256);
                app.Description = ini.Read("version", "description", 256);
                app.Forced      = StaticUtil.ToInt(ini.Read("version", "forced", 256));
                app.Url         = ini.Read("version", "url", 256);
                app.Md5         = ini.Read("version", "md5", 256);
                app.Size        = StaticUtil.ToInt(ini.Read("version", "size", 256));
                if (!CheckTools.isPoint(StaticUtil.VERSION))
                {
                    throw new Exception("系统版本号设置有误!");
                }
                if (!CheckTools.isPoint(app.Version))
                {
                    throw new Exception("远程版本号设置有误!");
                }
                if (float.Parse(app.Version) > float.Parse(StaticUtil.VERSION))
                {
                    app.IsUpdate = true;
                }
            }
            else
            {
                this.progress_file.Text = "正在检测版本号...";
                app = AutoVersionInfo.CheckIsUpdate(StaticUtil.VERSION);
            }
            UpdateApp();
        }