public static void UpdataDict(bool flag = false) { try { UpdateEnt data = ApiClient.GetUpdateInfo(Win.WinInput.ApiDictUrl); if (Win.WinInput.DictVersion != data.DictVersion) { //现在就可升级词库 #region 实现升级 bool updataok = false; string du = data.DictDownUrl; ///下载新词库 if (MessageBox.Show("有新词库,是否下载!\r\n", "有新词库", MessageBoxButtons.YesNo) == DialogResult.Yes) { Win.Login info = new Win.Login(false, Core.Win.WinInput.Input, 0); info.TopMost = true; info.Show(); try { WebClient client = new WebClient(); string filename = System.IO.Path.Combine(Win.WinInput.Input.AppPath, DateTime.Now.Ticks.ToString() + ".zip"); client.DownloadFile(du, filename); Thread.Sleep(200); if (File.Exists(filename)) { //下载完成解压 updataok = ZipClass.UnZip(filename, System.IO.Path.Combine(Win.WinInput.Input.AppPath, "dict", InputMode.CDPath), ""); Thread.Sleep(500); File.Delete(filename);//解压完成,删除下载的文件 updataok = true; Win.WinInput.DictVersion = data.DictVersion; Program.MIme.SaveDictSetting(); Program.MIme.InputIni(); info.Close(); } } catch { updataok = false; } } #endregion return; } } catch (Exception ex) { string ss = ex.ToString(); } }
public static void UpdataSoft(bool flag = false) { try { UpdateSoftEnt data = ApiClient.GetEnt(Win.WinInput.ApiUrl); if (Program.ProductVer != data.ProductVer) { //下载最新版本 #region 实现升级 bool updataok = false; string du = data.DownUrl; ///下载 if (MessageBox.Show("有新版本,是否现在升级!\r\n", "速录宝-有新版本", MessageBoxButtons.YesNo) == DialogResult.Yes) { Win.Login info = new Win.Login(false, Core.Win.WinInput.Input, 0); info.TopMost = true; info.Show(); try { WebClient client = new WebClient(); client = new WebClient(); string filename = System.IO.Path.Combine(Win.WinInput.Input.AppPath, "updatesoft.zip"); client.DownloadFile(du, filename); Thread.Sleep(200); updataok = true; } catch { updataok = false; } } if (updataok) { //关闭速录软件,打开升级解压程序 System.Diagnostics.Process.Start(System.IO.Path.Combine(Win.WinInput.Input.AppPath, "update.exe")); Program.MIme.ExitSelect(null, null); } #endregion return; } else if (flag) { MessageBox.Show("没有检测到要更新的程序!"); return; } } catch (Exception ex) { string ss = ex.ToString(); } }