我正在尝试从 DOS 树命令 (tree /F /A > treeList.txt) 的输出中填充 C# TreeView。我需要逐行确定文本文件中每个节点的级别并将其存储为整数。有没有办法可以通过正则表达式来确定?下面是 Tree 命令的输出示例:
Folder PATH listing
Volume serial number is ****-****
C:.
| info.txt
| treeList.txt
|
+---Folder1
| +---Sub1
| | | info.txt
| | | info2.txt
| | | info3.txt
| | |
| | \---Sub
| | | info.txt
| | |
| | \---Sub
| | info.txt
| | info2.txt
| |
| +---Sub2
| \---Sub3
+---Folder2
| | info.txt
| | info2.txt
| |
| +---Sub1
| | info.txt
| |
| +---Sub2
| +---Sub3
| | info.txt
| |
| \---Sub4
+---Folder3
| \---Sub1
+---Folder4
| +---Sub1
| \---Sub2
| info.txt
| info2.txt
|
\---Folder5
info.txt
这是我试图实现的输出示例:
info.txt 0
treeList.txt 0
Folder1 0
Sub1 1
info.txt 2
info2.txt 2
info3.txt 2
Sub 2
info.txt 3
Sub 3
info.txt 4
info2.txt 4
Folder2 0
And so on...
非常感谢任何帮助或指导。