C# 生成压缩包
引用 Nuget包 ICSharpCode.SharpZipLib
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
public class ZipHelper
{
/// <summary>
/// 生成压缩包
/// </summary>
/// <param name="folderPath">获取文件和目录的目录</param>
/// <param name="outputFilePath">创建的zip文件名称</param>
/// <param name="recurse">递归目录为True,不递归为false</param>
public static void CreateZip(string folderPath,string outputFilePath,bool recurse = false)
{
(new FastZip()).CreateZip(outputFilePath, folderPath, recurse, "");
}
}
}