+ffdf
+333
+3fdfd
+ffd
+fdfd
+fdd
如何得到最大层数为4层?
static int level=0;
getAllTreenode(treeView1.Nodes);
MessageBox.Show(level.ToString());
void getAllTreenode(TreeNodeCollection nodes)
{
foreach(TreeNode tn in nodes)
{
comparelevel(tn.FullPath,'\\');
if(tn.Nodes.Count>0)
{
getAllTreenode(tn.Nodes);
}
}
}
void comparelevel(string str1,char filter)
{
if(level<str1.Split(filter).Length)
{
level=str1.Split(filter).Length;
}
}