I have this tree structure.
How can i generate a folder path from it;
something like: folder1/chilfolder1/childfolder2/childfolder3
Do this for all folders in the tree :)
I have this tree structure.
How can i generate a folder path from it;
something like: folder1/chilfolder1/childfolder2/childfolder3
Do this for all folders in the tree :)
The objects that you are referring to as files and folders are just objects inside of a JSON serialized object. So, if you want to go about making URIs
(Unique Resource Identifiers), you should analyze this data and go node by node down into the object, adding a \
(path seperator) and a String
value of the current node name.
The easiest way would be using a well-known depth-first search algorithm. Consider the following c# pseudo-code:
class Node {
public string Name;
public IEnumerbale<Node> Children;
}
void Main(){
var tree = new List<Node>();//fill it somehow
foreach(var node in tree){
DFS(node);
}
}
void DFS(Node root){
foreach(var node in root.Children){
node.Name = root.Name + '/' + node.Name;
DFS(node);
}
}
After you run this code you'll get full names stored in Name
property of each Node