如何将TO添加到listBox驱动子目录和文件 [英] how to add TO listBox dirve & subdirectories & file

查看:61
本文介绍了如何将TO添加到listBox驱动子目录和文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加listBox驱动和子目录数据

how to add listBox dirve & subdirectories data

推荐答案

您不能只使用FolderBrowserDialog吗?

http://msdn.microsoft.com/en-us/library/system. windows.forms.folderbrowserdialog.aspx [ ^ ]

Can''t you just use FolderBrowserDialog?

http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx[^]

string folderPath = "";
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
    folderPath = folderBrowserDialog1.SelectedPath;
}




欢呼!




Cheers!


由于文件系统是分层的,很可能ListBox并没有得到足够的控制. (嗯,它比树更复杂,因为有链接和符号链接(Windows术语中的重新定义点),但是我们可以忘记它.)

对于要显示的内容,更充分的控制是TreeView.只有一个问题,但是却是一个非常棘手的问题:应该动态添加目录级别,并在用户扩展和折叠节点时将其删除,否则性能将不可接受.

这些文章的作者似乎做得对:
文件系统TreeView [ http://www.codingforums.com/showthread.php?t=98085 [ ^ ].

即使您坚持使用ListBox,阅读这些文章也会为您提供完成此任务可能需要的所有信息.

—SA
Most likely, ListBox is not adequate control, as the file systems is hierarchical. (Well, it''s more complex graph than a tree as there are links and symlinks (reparse points in Windows terminology), but we can forget about it.)

The more adequate control for what you want to show is TreeView. There is only one problem, but a pretty difficult one: the directory levels should be added dynamically and removed as the user expands and collapses nodes, otherwise performance would be unacceptable.

It looks like the authors of these article do it right:
Filesystem TreeView[^],
http://www.codingforums.com/showthread.php?t=98085[^].

Even if you insist on ListBox, reading of these articles will give you all information you may possibly need to accomplish this task.

—SA


有一个控件可以执行此操作
there is a control that do this


这篇关于如何将TO添加到listBox驱动子目录和文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆