Very simple concept but I am striking out here. I am trying to build a simple file explorer like Path but I can't seem to get it straight.
The method to build the Path is:
private string BuildFullPath(List<Project> Children)
{
string path = string.Empty;
foreach(Project project in Children)
{
if (this.ParentFolder == null)
{
path = this.Name;
}
else
{
path += this.ParentFolder.Name + " > " + this.Name;
}
}
return path;
}
And the fake data is
Projects = new ObservableCollection<Project>();
Project parentOne = new Project("Apple", true, null);
Project parentTwo = new Project("Samsung", true, null);
Project parentThree = new Project("Google", true, null);
Project parentFour = new Project("Amazon", true, null);
Project parentOneChildOne;
parentOneChildOne = new Project("Mac", true, parentOne);
Project parentOneChildTwo;
parentOneChildTwo = new Project("iPhone", true, parentOne);
Project parentOneChildThree;
parentOneChildThree = new Project("iPad", true, parentOne);
parentOne.Children.Add(parentOneChildOne);
parentOneChildOne.Children.Add(new Project("MacBook", true, parentOneChildOne));
parentOneChildOne.Children.Add(new Project("MacBook Pro", true, parentOneChildOne));
parentOneChildOne.Children.Add(new Project("MacBook Air", true, parentOneChildOne));
projects.Add(parentOne);
So the path for MacBook Pro should be Apple -> Mac- >MacBook -> MacBook Pro and the path for Mac should just be Apple -> Mac but can't seem to shake it.
Apple -> Mac- >MacBook -> MacBook Proexample I don't see you trying to add a-anywhere. Please show the exact string output you are trying to get and what you are actually getting.