using ICSharpCode.SharpZipLib.Zip; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MyCode.Project.Infrastructure.Common { public class ZipHelper { #region Zip(根据传递的路径压缩成一个文件) /// /// 根据传递的路径压缩成一个文件 /// /// /// public static void Zip(List filePaths, string savePath) { if (filePaths == null || filePaths.Count == 0) { } using (ZipFile zip = ZipFile.Create(savePath)) { zip.BeginUpdate(); foreach (var path in filePaths) { var fileName = Path.GetFileName(path); zip.Add(path, fileName); } zip.CommitUpdate(); } } #endregion } }