Bracket.Hosting.ZipArchiveDirectory.GetFileEntries C# (CSharp) Méthode

GetFileEntries() public méthode

public GetFileEntries ( string path, string searchPattern ) : string[]
path string
searchPattern string
Résultat string[]
        public string[] GetFileEntries(string path, string searchPattern)
        {
            //TODO:Ignoring searchPattern for the moment
            if (searchPattern != "*")
                throw new NotImplementedException("Search patterns other than * are not yet implemented");

            var found = new List<string>();

            if (IsRoot(path))
            {
                foreach (ZipEntry entry in _storage.Entries.Where(entry => entry.IsDirectory == false && VirtualFileUtils.IsTopLevel(entry.FileName)))
                {
                    found.Add(GetFullName(entry.FileName));
                }
                return found.ToArray();
            }

            foreach (ZipEntry entry in _storage.Entries)
            {
                if (entry.IsDirectory)
                    continue;

                string normalizedFile = VirtualFileUtils.NormalizePath(entry.FileName);
                string directory = VirtualFileUtils.NormalizePath(Path.GetDirectoryName(normalizedFile));
                string target = RemoveRoot(path);

                if (String.Compare(target, directory, true) == 0)
                    found.Add(GetFullName(normalizedFile));
            }

            return found.ToArray();
        }

Usage Example

 public void GetFilesShouldReturnFilesInRoot()
 {
     //Given
     var dir = new ZipArchiveDirectory("Fresh.zip");
     //when
     string[] files = dir.GetFileEntries(".", "*");
     //then
     Assert.That(files.Length, Is.EqualTo(2));
     Assert.That(files[1], Is.EqualTo(FullPath("file1.txt")));
 }
All Usage Examples Of Bracket.Hosting.ZipArchiveDirectory::GetFileEntries