作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
不知道有没有办法用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/
不知道有没有办法用fastzip压缩一个目录,但只包括某些文件类型。我正在考虑使用类似的东西: public static void ZipFiles(string DirectoryToZi
我正在使用 ICSharpCode.SharpZipLib.Zip.FastZip 来压缩文件,但我遇到了一个问题: 当我尝试压缩文件名中包含特殊字符的文件时,它不起作用。它在文件名中没有特殊字符时有
我在使用 Mono 的 Mac 上使用以下代码来解压缩 zip 文件。 zip 文件包含目录下的条目(例如 foo/bar.txt)。但是,在解压后的目录中,FastZip 不是创建目录 foo 和文
我正在使用 SharpZipLib 中的 FastZip 类创建一个 zip 文件,一旦关闭程序,我就无法删除该文件,因为: “无法删除 zip.zip:它正在被其他人或程序使用。请关闭所有可能正在使
我是一名优秀的程序员,十分优秀!