using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ICSharpCode.SharpZipLib.Zip; namespace TinaX.Utils { public static class ZipUtil { public static void ZipDirectory(string directory,string output_filename) { var fastzip = new FastZip(); fastzip.CreateZip(output_filename, directory, true, ""); } /// /// Create Zip file by directory , with process callback /// /// /// /// string arg: file name public static void ZipDirectory(string directory, string output_filename, Action callback) //带数据回调 { TinaX.IO.XFile.DeleteIfExists(output_filename); FastZipEvents events = new FastZipEvents(); events.ProcessFile = (sender, args) => { callback?.Invoke(args.Name); }; var fastzip = new FastZip(events); fastzip.CreateZip(output_filename, directory, true, ""); } public static void UnZip(string zip_path,string target_dir) { FastZip fastzip = new FastZip(); fastzip.ExtractZip(zip_path, target_dir, null); } } }