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()); }
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); } }
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); } }
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; } } }
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); }
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; } } }
public void Clear() { directory_list.Clear(); error_list.Clear(); node = null; }
public void AddItem(FileIndexorNode node) { nodes.Add(node); }