c# - 使用 SharpZipLib 打包空目录

标签 c# zip

我想使用 SharpZipLib 打包压缩一些文件夹。示例结构

directory1:
    directory2:
         file1
    file2
    directory3:
        directory4:

当我使用此处的 C# 代码打包它时:

http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx#Create_a_Zip_with_full_control_over_contents_0

我得到没有 directory3directory4 的 zip 文件。

我的问题是如何打包以获取包含 directory3directory4 的文件。

最佳答案

 FastZip fastZip = new FastZip();

 fastZip.CreateEmptyDirectories = true;
 // Include all files by recursing through the directory structure
 bool recurse = true; 
 // Dont filter any files at all 
 string filter = null;
 fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);

需要注意的是它无法处理 UTF-8 文件名。

这是文档 wiki 的链接:

http://wiki.sharpdevelop.net/SharpZipLib_FastZip.ashx

关于c# - 使用 SharpZipLib 打包空目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9303919/

相关文章:

c# - 如何在我的 WPF 表单中为我的 BackgroundImage 设置图像?

c# - 从 Form2 中获取 Form1 的复选框值

c# - 使用 Console.Write 字符串格式化

c# - 存储过程返回许多记录,但 DataReader 只看到一个

linux - tar -czf 的结果

c# - 具有多种条件的下拉列表 - 从数据库中选择

linux - 如果从 cron 运行,zip 会创建空文件

java - Gradle Zip 任务做多个子树?

python - 如何在 Python 中对 "unzip"然后切片并查找列表列表中元素的最大值

c# - C# 中 ionic zip 的替代品是什么?