This project is read-only.

AddDirectory without including hidden files and folders

Jul 22, 2011 at 10:59 PM

Is there a way to add a directory without including hidden files and folders?  For example if I try to zip a directory which is in Subversion source control is there a way to add the directory without including any of the .svn sub directories?

Jul 23, 2011 at 3:10 PM

You have a couple options -

  1. use one of the the AddSelectedFiles() overloads . Specify "attr != H" in the criterion string.
  2. select the files yourself (using LINQ for example) and then call AddFiles(). 

For an example of using LINQ, how about this:

using (var zip = new ZipFile())
    // select only non-hidden files 
    var fileNames = (from fn in Directory.GetFiles(directoryName, "*.*", SearchOption.AllDirectories)
                where ((File.GetAttributes(fn) & FileAttributes.Hidden) == 0)
                select fn).ToList();
Jul 25, 2011 at 5:54 PM

These are some great alternatives; I'll give them a try.  Thanks.