#region 文件压缩
/// <summary>
/// 将文件夹压缩
/// </summary>
/// <param name="srcFiles">文件夹路径</param>
/// <param name="strZip">压缩之后的名称</param>
public void ZipFile(string srcFiles, string strZip)
{
ZipOutputStream zipStream = null;
try
{
var len = srcFiles.Length;
var strlen = srcFiles[len - 1];
if (srcFiles[srcFiles.Length - 1] != Path.DirectorySeparatorChar)
{
srcFiles += Path.DirectorySeparatorChar;
}
zipStream = new ZipOutputStream(File.Create(strZip));
zipStream.SetLevel(6);
zip(srcFiles, zipStream, srcFiles);
zipStream.Finish();
zipStream.Close();
}
catch (Exception ex)
【c#】文件夹压缩
最新推荐文章于 2024-07-22 15:56:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)