Note: I do not have a network to experiment with. Attached is some generic code to map a text file where the line structure reflects a tree structure with some text-delimiter repeated to indicate node level: note, this is code I wrote some time ago, and does not include robust error-checking;
use as is at your own risk.
Suggest you review: [
^]
The code here is, imho, simpler, and, I think can be easily adapted by you: [
^]
And, CodeProject is your friend: start here: [
^]
also see: [
^], [
^], [
^]
Code example:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace YourNameSpace
{
public static class StringToTreeView
{
private static char[] linesplitter;
private static TreeNode node;
public static Dictionary<int, TreeNode> levelToNode = new Dictionary<int, TreeNode>();
public static void Map(string source, char linesplit, char levelindicator, ref TreeView tv)
{
levelToNode.Clear();
string[] lines = source.Split(new char[] { linesplit }, StringSplitOptions.RemoveEmptyEntries);
TreeNode parentNode;
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i];
string trimmed = line.TrimStart(levelindicator);
int level = line.Length - trimmed.Length;
node = new TreeNode(trimmed);
levelToNode[level] = node;
if (level == 0)
{
tv.Nodes.Add(node);
}
else
{
if (levelToNode.TryGetValue(level - 1, out parentNode))
{
parentNode.Nodes.Add(node);
}
else
{
throw new AccessViolationException($"\r\nerror in node definition: level exceeds current use {node.Text}\r\n");
}
}
}
}
}
}
A usage example:
string src = @"one,*two,**three,four,*five,**six,***seven,****eight,**nine";
StringToTreeView.Map(src, ',', '*', ref YOURTREEVIEW);