In order to achieve this, you will need to use the CopyFilesTo method. The CopyTo method will take your BaseFolder and place it in a ZipArchive. You will not be able to filter the directory. The CopyTo folder will only be able to satisfy your third condition where you want it to include the current BaseFolder directory plus its children. As for the other conditions, you can do the following:
1) some of which I want to zip NOT including any subfolder eg Folder1
--> source.CopyFilesTo(zEvents, "source.CopyFilesTo", zip, false, true, "");
Must set the recursive property to false in your parameter list. Because you will be setting recursive to false, the CopyFilesTo will not copy the subdirectories and their files over to the ZipArchive.
2) some of which I want to zip including SOME subfolders eg Folder2\Sub1 and Folder2\Sub2, but not Folder2\Sub3
source.CopyFilesTo(zEvents, "source.CopyFilesTo", zip, true, true, new
NotFilter(new NameFilter("Test 1", FilterScope.Recurse)));
The only way to do this is to list the folder that you do NOT want to copy to your ZipArchive. In order to do this, you will need to provide a NotFilter as your filter so that the CopyFilesTo method will not copy the directories that you stated in your ZipArchive.
3) some of which I want to zip including ALL subfolders eg Folder3\Sub1...Sub4
--> source.CopyFilesTo(zEvents, "source.CopyFilesTo", zip, true, true, "");
You can do the following operation, or you can simply use the CopyTo method. We are simple setting the recursive property to true so that the CopyFilesTo method will copy everything and place it in your ZipArchive.
Developer in Technical Support
Xceed - Multi-talented components - http://xceed.com