public static bool TarExtract() { try { //define extracting options Ionic.Tar.Options tar = new Ionic.Tar.Options(); //set overwrite to true tar.Overwrite = true; tar.Path = filePath; //extract shallalist.tar.gz var entries = Ionic.Tar.Extract(filePath + fileName, tar); //return true if extracting was success return(true); } catch (Exception) { //return false if extracting failed return(false); } }
public static bool TarExtract() { try { //define extracting options Ionic.Tar.Options tar = new Ionic.Tar.Options(); //set overwrite to true tar.Overwrite = true; tar.Path = filePath; //extract shallalist.tar.gz var entries = Ionic.Tar.Extract(filePath + fileName, tar); //return true if extracting was success return true; } catch (Exception) { //return false if extracting failed return false; } }
private void OnDownloadCompleted(object sender, UpdateChecker.DownloadEventArgs e) { try { string text = null; if (e.Error != null) { text = string.Format(I18N.GetString("failed to download {0}"), e.Release.name); ShowBalloonTip("", text, ToolTipIcon.Error, 3000); if (File.Exists(e.SaveTo)) { try { File.Delete(e.SaveTo); } catch (Exception ex) { Logging.LogUsefulException(ex); } } } else { #if TAR string arch = Environment.Is64BitOperatingSystem ? "amd64" : "386"; string dstFilename = controller.KCPTunnelController.GetKCPTunPath(); try { Directory.SetCurrentDirectory(Utils.GetTempPath()); Ionic.Tar.Options opts = new Ionic.Tar.Options(); opts.Overwrite = true; Ionic.Tar.Extract(e.SaveTo, opts); Directory.SetCurrentDirectory(Application.StartupPath); bool running = controller.KCPTunnelController.IsRunning; if (running) { controller.KCPTunnelController.Stop(); } if (File.Exists(dstFilename)) { File.Delete(dstFilename); } File.Move(Utils.GetTempPath($"client_windows_{arch}.exe"), dstFilename); if (running) { controller.KCPTunnelController.Start(); } if (File.Exists(Utils.GetTempPath($"client_windows_{arch}.exe"))) { File.Delete(Utils.GetTempPath($"client_windows_{arch}.exe")); } if (File.Exists(Utils.GetTempPath($"server_windows_{arch}.exe"))) { File.Delete(Utils.GetTempPath($"server_windows_{arch}.exe")); } if (File.Exists(e.SaveTo)) { File.Delete(e.SaveTo); } text = string.Format(I18N.GetString("kcptun updated to {0}"), controller.KCPTunnelController.GetKcptunVersionNumber()); ShowBalloonTip("", text, ToolTipIcon.Info, 3000); } catch (Exception ex) { Logging.LogUsefulException(ex); text = string.Format(I18N.GetString("failed to uncompress {0}"), e.SaveTo); ShowBalloonTip("", text, ToolTipIcon.Error, 3000); } finally { Directory.SetCurrentDirectory(Application.StartupPath); } #else text = string.Format(I18N.GetString("New kcptun version {0} is available"), e.Release.version); ShowBalloonTip("", text, ToolTipIcon.Error, 3000); string argument = "/select, \"" + e.SaveTo + "\""; Process.Start("explorer.exe", argument); #endif } } catch (Exception ex) { Logging.LogUsefulException(ex); } }