不知道有没有办法用fastzip压缩一个目录,但只包括某些文件类型。我正在考虑使用类似的东西:
public static void ZipFiles(string DirectoryToZip, string ZipedFile, string fileFilter, string folderFilter) {
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true;
fz.CreateZip(ZipedFile, DirectoryToZip, true, fileFilter, folderFilter);
}
唯一的问题是 fileFilter
是在 string
中给出的,而不是在 arrays
中。
有什么想法吗?
最佳答案
我解决了我自己的问题;事实证明,我只需要提供一个正则表达式字符串来过滤我想要的类型。
这里是一个只包含 excel 文件、word 文件和 xml 文件到 zip 中的例子。
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true;
fz.CreateZip(zipFile, prjDir, true, ".*\\.(xls|doc|xml)$", "");
关于c# - 使用 FastZip 压缩目录,并且只包含某些文件类型(文件过滤),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1671491/