如何在C#.net中将目录中的文件夹和子文件夹列出到Treeview

编程入门 行业动态 更新时间:2024-10-28 02:34:55
本文介绍了如何在C#中将目录中的文件夹和子文件夹列出到Treeview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我想用驱动器中所有文件夹和子文件夹的列表填充treeview 我有一个Windows窗体,上面有一个树状视图.我想用目录中的所有文件夹和子文件夹填充它.我为此搜索了Google,但没有得到任何好的资源,对此有什么帮助吗? 假设我选择D:\,则树视图将加载D:\ 中的所有文件夹和子文件夹 任何帮助将是thankfull

Hi all, I want to populate a treeview with the list of all folders and subfolders from a Drive I have a Windows form having a tree view on it. I want to populate it with all folders and subfolders from a Directory. I googled for this, and didnt get any good source, could any one help on this? Say if i select D:\ , then the treeview loads with all folders and subfolders in D:\ Any help will be thankfull

推荐答案

集中在一个节点上.它应该代表一条路径.使用 GetDirectories [ ^ ]方法.为每个子目录创建一个子节点.如果用户展开子节点之一,请重复此操作. Concentrate on one node. It should represent a path. Get all its subdirectories using the GetDirectories[^] method. Create a child node for every subdirectory. Repeat if user expands one of the child nodes.

请参考以下链接. social.msdn.microsoft/论坛/en-US/csharpgeneral/thread/1c89fa5d-1dd1-4f11-aeca-8ba157d673bf [ ^ ] 列出文件夹和子文件夹 [ ^ ] Hi, Please refer the below link for the same. social.msdn.microsoft/Forums/en-US/csharpgeneral/thread/1c89fa5d-1dd1-4f11-aeca-8ba157d673bf[^] Listing Folder and SubFolder[^]

更多推荐

如何在C#.net中将目录中的文件夹和子文件夹列出到Treeview

本文发布于:2023-10-08 23:56:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   中将   如何在   目录中   Treeview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!