Using FastZip for a Zip directory and including only certain types of files (file filtering)

I wonder if there is a way to use fastzip for a zip directory, but include only certain types of files. I am thinking of 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 what fileFilteris given in string, not in arrays.

Any ideas?

+3
source share
2 answers

I solved my problem; it turns out that I just have to provide a regex string to filter the types that I want.

Here is an example that includes only excel file, word file and xml file in zip.

        FastZip fz = new FastZip();
        fz.CreateEmptyDirectories = true;

        fz.CreateZip(zipFile, prjDir, true, ".*\\.(xls|doc|xml)$", "");
+4
source

FastZip ?

, Directory.GetDirectories() , .

0

Source: https://habr.com/ru/post/1721842/


All Articles