public static IEnumerable <ZipEntryInfo> EnumerateEntryInfos(this ZipFile archive,
                                                                     string path, Regex searchPatternRegex, SearchOption searchOption, EntryInfoTypes entryInfoTypes)
        {
            if (path == null)

            {
                path = "";
            }

            if (path.Length > 0)
            {
                path = path.Trim(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                path = path + Path.AltDirectorySeparatorChar;
            }

            HashSet <string> found = new HashSet <string>();

            foreach (ZipEntry entry in archive)
            {
                if (path.Length > 0 && !entry.Name.StartsWith(path))
                {
                    continue;
                }

                int nextSeparator = entry.Name.IndexOfAny(_pathSeparators, path.Length);

                if (nextSeparator >= 0)
                {
                    string directoryName = entry.Name.Substring(0, nextSeparator + 1);

                    if (found.Add(directoryName))
                    {
                        if (entryInfoTypes.HasFlag(EntryInfoTypes.Directory))
                        {
                            yield return(new ZipDirectoryInfo(entry, directoryName));
                        }

                        if (searchOption == SearchOption.AllDirectories)
                        {
                            foreach (ZipEntryInfo info in
                                     archive.EnumerateEntryInfos(
                                         directoryName, searchPatternRegex, searchOption, entryInfoTypes))
                            {
                                yield return(info);
                            }
                        }
                    }
                }
                else
                {
                    if (entryInfoTypes.HasFlag(EntryInfoTypes.File))
                    {
                        if (PatternOk(entry.Name, searchPatternRegex))
                        {
                            yield return(new ZipFileInfo(entry, entry.Name));
                        }
                    }
                }
            }
        }
 public static IEnumerable <ZipEntryInfo> EnumerateEntryInfos(
     this ZipFile archive, string path, string searchPattern, EntryInfoTypes entryInfoTypes)
 {
     return(archive.EnumerateEntryInfos(
                path, searchPattern, SearchOption.TopDirectoryOnly, entryInfoTypes));
 }
        public static IEnumerable <ZipEntryInfo> EnumerateEntryInfos(this ZipFile archive,
                                                                     string path, string searchPattern, SearchOption searchOption, EntryInfoTypes entryInfoTypes)
        {
            Regex searchPatternRegex = searchPattern.WildcardToRegex(true);

            foreach (ZipEntryInfo info in archive.EnumerateEntryInfos(path, searchPatternRegex, searchOption, entryInfoTypes))
            {
                yield return(info);
            }
        }
    public static IEnumerable <ZipEntryInfo> EnumerateEntryInfos(this ZipArchive archive,
                                                                 string path, SearchOption searchOption, EntryInfoTypes entryInfoTypes)
    {
        // Normalize input path, by removing any path separator character from the
        // beginning, and ensuring one is present at the end. This will ensure that
        // the path variable format matches the format used in the archive and which
        // is also convenient for the implementation of the algorithm below.
        if (path.Length > 0)
        {
            if (_pathSeparators.Contains(path[0]))
            {
                path = path.Substring(1);
            }
            if (!_pathSeparators.Contains(path[path.Length - 1]))
            {
                path = path + Path.AltDirectorySeparatorChar;
            }
        }
        HashSet <string> found = new HashSet <string>();

        foreach (ZipArchiveEntry entry in archive.Entries)
        {
            if (path.Length > 0 && !entry.FullName.StartsWith(path))
            {
                continue;
            }
            int nextSeparator = entry.FullName.IndexOfAny(_pathSeparators, path.Length);
            if (nextSeparator >= 0)
            {
                string directoryName = entry.FullName.Substring(0, nextSeparator + 1);
                if (found.Add(directoryName))
                {
                    if (entryInfoTypes.HasFlag(EntryInfoTypes.Directory))
                    {
                        yield return(new ZipDirectoryInfo(directoryName));
                    }
                    if (searchOption == SearchOption.AllDirectories)
                    {
                        foreach (ZipEntryInfo info in
                                 archive.EnumerateEntryInfos(
                                     directoryName, searchOption, entryInfoTypes))
                        {
                            yield return(info);
                        }
                    }
                }
            }
            else
            {
                if (entryInfoTypes.HasFlag(EntryInfoTypes.File))
                {
                    yield return(new ZipFileInfo(entry.FullName));
                }
            }
        }
    }