码迷,mamicode.com
首页 > Web开发 > 详细

asp.net无限递归

时间:2019-02-15 22:42:54      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:ext   cto   eve   node   public   TreeView   private   net   void   

private void button1_Click(object sender, EventArgs e)
{
DialogResult dialogResult = folderBrowserDialog1.ShowDialog();
if (dialogResult == DialogResult.OK)
{
DirectoryInfo directoryInfos = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
TreeNode treeNode = new TreeNode();
treeNode.Text = directoryInfos.Name;
treeView1.Nodes.Add(treeNode);
Tree(treeNode, directoryInfos);
}
}
public void Tree(TreeNode treeNode, DirectoryInfo directoryInfo)
{
DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories();
foreach (DirectoryInfo item in directoryInfos)
{
TreeNode tree = new TreeNode();
tree.Text = item.Name;
treeNode.Nodes.Add(tree);
FileInfo[] fileInfos = item.GetFiles();
if (fileInfos != null)
{
foreach (var items in fileInfos)
{
TreeNode tr = new TreeNode();
tr.Text = items.Name;
tree.Nodes.Add(tr);
}
}
Tree(tree, item);
}
}

asp.net无限递归

标签:ext   cto   eve   node   public   TreeView   private   net   void   

原文地址:https://www.cnblogs.com/LYYXXXX/p/10386134.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!