I was expecting that calling AddNodeByPath would automatically create the necessary parent nodes similar to how Directory.Create() works.
However, it just seems to add them all to the closest node it could find (if there are no nodes, then a bunch of "Report.txt" will be in the root node).
I have come up with the following to solve this issue, but I'm wondering if there's an easier way?
Is this a bug, or is it documented somewhere that AddNodeByPath() doesn't create the necessary parent nodes?
treeView.AddNodeByPath(
"General\\Billing\\February\\Report.txt"
)
treeView.AddNodeByPath(
"General\\Billing\\March\\Report.txt"
)
treeView.AddNodeByPath(
"General\\Billing\\April\\Report.txt"
)
However, it just seems to add them all to the closest node it could find (if there are no nodes, then a bunch of "Report.txt" will be in the root node).
I have come up with the following to solve this issue, but I'm wondering if there's an easier way?
private
RadTreeNodeCollection AddNode(
string
path)
{
if
(path == String.Empty)
return
treeView.Nodes;
string
node = Path.GetFileName(path);
RadTreeNodeCollection parent = AddNode(Path.GetDirectoryName(path));
if
(parent.Contains(node))
return
parent[node].Nodes;
else
return
parent.Add(node).Nodes;
}
Is this a bug, or is it documented somewhere that AddNodeByPath() doesn't create the necessary parent nodes?