I wonder whether there is a way to use fastzip to zip a directory, but include only certain file types. I am thinking about using something like:
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);
}
The only problem is that the fileFilter
is given in string
, not in arrays
.
Any ideas?
I solved my own problem; it turns out that I just have to provide a regular expression string to filter the types I want.
Here's an example to include only excel file, word file and xml file into the zip.
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true;
fz.CreateZip(zipFile, prjDir, true, ".*\\.(xls|doc|xml)$", "");