private void _UpdateSucess() { Mydebug.MyDEBUG("成功更新"); this.Invoke(new UIperDelegate(_UpdateUI), new object[] { UItype.UpdateProgress, 100 }); if (!string.IsNullOrEmpty(_startExePath)) { KillExe.StartExeByCMD(_startExePath); ScreenTool.MinScreen(); Mydebug.MyDEBUG("启动:" + _startExePath); Console.WriteLine("更新完成功启动" + _startExePath); } else { Mydebug.MyDEBUG("未启动:启动前exe未运行"); Console.WriteLine("更新完成功未启动:启动前exe未运行"); } _zipTest.Clear(); if (_boolonlyOne) { Thread.Sleep(1500); Application.Exit(); _httpDownload.Clear(); } else { _isdownloading = false; _httpDownload.Clear(); } }
private void _UzipErr() { this.Invoke(new UIperDelegate(_UpdateUI), new object[] { UItype.Uziptext, 0 }); _zipTest.Clear(); if (!string.IsNullOrEmpty(_startExePath)) { KillExe.StartExeByCMD(_startExePath); ScreenTool.MinScreen(); Mydebug.MyDEBUG("解压到本地失败,启动:" + _startExePath); Console.WriteLine("解压到本地失败,启动" + _startExePath); } else { Mydebug.MyDEBUG("解压到本地失败,未启动"); Console.WriteLine("解压到本地失败,未启动"); } if (_boolonlyOne) { Thread.Sleep(1500); Application.Exit(); _httpDownload.Clear(); } else { _isdownloading = false; _httpDownload.Clear(); } }
private void _UpdateFile(string filePath) { Console.WriteLine("准备更新:" + filePath); //开始替换更新包 if (Directory.Exists(filePath)) { Console.WriteLine("____________0_____________"); if (Directory.Exists(_updatePath)) { Console.WriteLine("____________01_____________"); //DirectoryInfo inff = new DirectoryInfo(_updatePath); //List<IntPtr> explorer = User32API.GetWindowHandleByName("explorer"); //Console.WriteLine("资源管理器长度:"+explorer.Count); //if (explorer.Count > 0) //{ // Console.WriteLine("资源管理器[0]:" + explorer[0]); // //KillExe.KillExeByCMD("explorer.exe"); // //KillExe.StartExeByCMD("explorer.exe"); //} _OverwiteDirectory(filePath, _updatePath); //try //{ // inff.Delete(true); //} //catch (Exception ex) //{ // KillExe.KillExeByCMD("explorer.exe"); // inff.Delete(true); // KillExe.StartExeByCMD("explorer.exe"); //} } else { Directory.CreateDirectory(_updatePath.Substring(0, _updatePath.LastIndexOf('\\'))); DirectoryInfo info = new DirectoryInfo(filePath); try { info.MoveTo(_updatePath); } catch (Exception ex) { KillExe.KillExeByCMD("explorer.exe"); info.MoveTo(_updatePath); KillExe.StartExeByCMD("explorer.exe"); } } Console.WriteLine("更新完成:" + _updatePath); _UpdateSucess(); } else { Mydebug.MyDEBUG("!!!更新失败"); this.Invoke(new UIperDelegate(_UpdateUI), new object[] { UItype.Updatetext, 0 }); _zipTest.Clear(); if (!string.IsNullOrEmpty(_startExePath)) { KillExe.StartExeByCMD(_startExePath); ScreenTool.MinScreen(); Mydebug.MyDEBUG("更新指定位置失败,启动:" + _startExePath); Console.WriteLine("更新指定位置失败,启动" + _startExePath); } else { Mydebug.MyDEBUG("更新指定位置失败,未启动"); Console.WriteLine("更新指定位置失败,未启动"); } if (_boolonlyOne) { Thread.Sleep(1500); Application.Exit(); _httpDownload.Clear(); } else { _isdownloading = false; _httpDownload.Clear(); } } }