4

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?

Graviton
  • 81,782
  • 146
  • 424
  • 602

2 Answers2

5

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)$", "");
Graviton
  • 81,782
  • 146
  • 424
  • 602
0

Can't you to create your FastZip instance and to add more files later?

If you can, you could to use Directory.GetDirectories() method to filter your files and just include that you want.

Rubens Farias
  • 57,174
  • 8
  • 131
  • 162