office politics
It's all just 1s and 0s
- Messages
- 6,555
- Location
- in the lab
I'm having trouble creating a file tree. I made notes on how to list files without recursion; see below. I'm not too keen on making on making objects. I think I want an object with string and a array that will hold the next level of objects. The node is the parent folder. The array is the subfolders and files. The object will contain a method that adds a object to it array.
I tried using the following code to make the object, but there's prolly something seriously wrong here.
Notes:
I tried using the following code to make the object, but there's prolly something seriously wrong here.
Code:
private class FileTree {
private string node;
private List<FileTree> = new List<FileTree>;
}
Notes:
Code:
filetree
node - string
childs - array of filetree
AddChild(item); - create new filetree with item as node
list files - returns filetree
create a stack of folders to check
add server path
do
pop server path off the stack
get directory listing of server path - return array (list of files & folders)
add each list item as child to serverpath
AddChild(serverpath + listString);
push folder server paths onto stack
while stack.count > 0