开发者

Using FastZip to zip a directory, and only include certain file types ( file filtering)

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, file开发者_如何学JAVAFilter, 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)$", "");


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜