Esempio n. 1
0
        private DirectoryTree BuildTree(string path)
        {
            var tree = new DirectoryTree(path);

            BuildTreeRecursion(tree);
            return(tree);
        }
Esempio n. 2
0
        private DirectoryTree AppendTree(DirectoryTree tree, bool isTextSearch)
        {
            var result = new DirectoryTree(tree);

            AppendTreeRecursion(result, isTextSearch);
            return(result);
        }
Esempio n. 3
0
 private void BuildTreeRecursion(DirectoryTree tree)
 {
     foreach (var str in _fileSystem.Directory.GetDirectories(tree.Name)
              .Select(str => new DirectoryTree(_fileSystem.Path.GetDirectoryName(str))))
     {
         if (str.Name == tree.Name)
         {
             continue;
         }
         tree.SubDirectories.Add(str);
         BuildTreeRecursion(str);
     }
 }
Esempio n. 4
0
        private void AppendTreeRecursion(DirectoryTree tree, bool isTextSearch)
        {
            if (isTextSearch)
            {
                foreach (var file in ConfigurationManager.AppSettings["TextFileFormats"].Split('|')
                         .SelectMany(str => _fileSystem.Directory.GetFiles(tree.Name, str)))
                {
                    tree.Files.Add(file);
                }
            }

            else
            {
                foreach (var file in _fileSystem.Directory.GetFiles(tree.Name))
                {
                    tree.Files.Add(file);
                }
            }

            foreach (var dir in tree.SubDirectories)
            {
                AppendTreeRecursion(dir, isTextSearch);
            }
        }
Esempio n. 5
0
 public DirectoryTree GetAllTextFiles(DirectoryTree tree)
 {
     return(AppendTree(tree, true));
 }
Esempio n. 6
0
 public DirectoryTree GetAllFiles(DirectoryTree tree)
 {
     return(AppendTree(tree, false));
 }