I have the struct:
public struct BaseFile
{
public string FileName;
public string Path; // this is not the full path. it is the fullPath of it's parent directory in other words.
}
and I have the class
public class MyFileDir // can be a file or directory
{
public string Name;
public string FullPath;
public List<MyFileDir> Children;
public bool IsDirectory;
// many more other properties
}
So I have one thread place files on LinkedList<BaseFile> myLinkedList
and I will like another thread to start casting those files too MyFileDir root
(note I used linkedList instead of list because the addresses of linkedList does not change where a List changes its address every time it needs to grow)
I have a bool variable IsRunning that will let me know if the other thread is still adding base files to the linked list. So I have something like:
var curNode = myLinkedList.First;
while (IsRunning)
{
if (curNode.Next == null) // wait until next node is not null
{
Thread.Sleep(100);
continue;
}
curNode = curNode.Next;
AddItemToTree(curNode.Value);
}
so as you can see I am having trouble implementing the method AddItemToTree
I basically will like to start building the tree in that method. So first I will look at the root and search the directory where I should add curNode.Value
. I am having a hard time doing that.