示例#1
0
        public async Task ListingDirectoryAsync(string target_directory)
        {
            root_directory = target_directory;
            await Task.Run(() => prelistingFolder(target_directory));

            directory_list.Sort();
            node = new FileIndexorNode(target_directory, 0);
            await Task.Run(() => createNodes());
        }
示例#2
0
 private void make_tree(FileIndexorNode fn, TreeNode tn)
 {
     foreach (FileIndexorNode n in fn.Nodes)
     {
         make_node(tn.Nodes, Path.GetFileName(n.Path.Remove(n.Path.Length - 1)));
         make_tree(n, tn.Nodes[tn.Nodes.Count - 1]);
     }
     foreach (FileInfo f in new DirectoryInfo(fn.Path).GetFiles())
     {
         make_node(tn.Nodes, f.Name);
     }
 }
示例#3
0
        private void listing(FileIndexor fi)
        {
            FileIndexorNode node = fi.GetRootNode();

            foreach (FileIndexorNode n in node.Nodes)
            {
                make_node(PathTree.Nodes, Path.GetFileName(n.Path.Remove(n.Path.Length - 1)));
                make_tree(n, PathTree.Nodes[PathTree.Nodes.Count - 1]);
            }
            foreach (FileInfo f in new DirectoryInfo(node.Path).GetFiles())
            {
                make_node(PathTree.Nodes, f.Name);
            }
        }
示例#4
0
 private void createNodes()
 {
     for (; index < directory_list.Count - 1; index++)
     {
         FileIndexorNode _node = new FileIndexorNode(directory_list[index].Item1, directory_list[index].Item2, listing_files);
         if (directory_list[index + 1].Item1.Contains(directory_list[index].Item1))
         {
             node.AddItem(_node);
             index += 1;
             createNodesRecursize(ref _node);
             break;
         }
     }
 }
示例#5
0
        public FileIndexorNode GetPathNode(string path)
        {
            string[]        seperated = path.Split('\\');
            string          section   = "";
            FileIndexorNode n         = node;

            for (int i = 0; i < seperated.Length; i++)
            {
                section += seperated[i] + '\\';
                foreach (FileIndexorNode nd in n.Nodes)
                {
                    if (nd.Path == section)
                    {
                        n = nd; break;
                    }
                }
            }
            return(n);
        }
示例#6
0
 private void createNodesRecursize(ref FileIndexorNode parent_node)
 {
     for (; index < directory_list.Count; index++)
     {
         if (directory_list[index].Item1.Contains(parent_node.Path))
         {
             FileIndexorNode m = new FileIndexorNode(directory_list[index].Item1, directory_list[index].Item2, listing_files);
             parent_node.AddItem(m);
             if (index < directory_list.Count - 1 &&
                 directory_list[index + 1].Item1.Contains(directory_list[index].Item1))
             {
                 index++;
                 createNodesRecursize(ref m);
             }
             parent_node.Size += m.Size;
         }
         else
         {
             index--;
             break;
         }
     }
 }
示例#7
0
 public void Clear()
 {
     directory_list.Clear();
     error_list.Clear();
     node = null;
 }
示例#8
0
 public void AddItem(FileIndexorNode node)
 {
     nodes.Add(node);
 }