-
Notifications
You must be signed in to change notification settings - Fork 980
FastZip
FastZip fastZip = new FastZip();
bool recurse = true; // Include all files by recursing through the directory structure
string filter = null; // Dont filter any files at all
fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);
If the file filter is not a null string, it is interpreted as a regular expression which is tested against each file name.
For example, a fileFilter value of 'txt' would match with 'Test.txt' but would also match with 'SometxtFile.doc'. To match with '.txt' you would need to add a a dot, but even then a filter of ".txt" would be interpreted as [any-character]txt. You need to add an escape character "" before the dot to specify it as a literal match. However, in my tests doing a single \ didn't seem to work, I needed to add a second .
Note that ".txt" would still match a file such as "file.txtold" or "file.txt.old", so you can append the $ specifier which matches with the end of the string: e.g ".txt$" to ensure you only match files with the last extension as .txt
FastZip fastZip = new FastZip();
bool recurse = true; // Include all files by recursing through the directory structure
string filter = @"\\.txt$"; // Only files ending in ".txt"
fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);