如何在C#.net中将目录中的文件夹和子文件夹列出到Treeview [英] How to list folders and subfolders from a directory to treeview in c#.net
本文介绍了如何在C#.net中将目录中的文件夹和子文件夹列出到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.
请参考以下链接.
http://social.msdn.microsoft.com/论坛/en-US/csharpgeneral/thread/1c89fa5d-1dd1-4f11-aeca-8ba157d673bf [列出文件夹和子文件夹 [ ^ ]
Hi,
Please refer the below link for the same.
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1c89fa5d-1dd1-4f11-aeca-8ba157d673bf[^]
Listing Folder and SubFolder[^]
这篇关于如何在C#.net中将目录中的文件夹和子文件夹列出到Treeview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文