Winforms中的文件资源管理器或浏览器 [英] File Explorer or Browser in winforms

查看:93
本文介绍了Winforms中的文件资源管理器或浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能指导我如何在Winforms中创建文件资源管理器


我的要求是,我希望树状视图显示系统目录中的所有目录,单击树状视图中的特定文件夹后,我要在列表视图中显示所有带有大小和日期的文本文件,包括图标. br/>
任何人都可以指导我如何执行此操作.

在此先感谢.

谢谢和问候,
Aditya Kiran M.

Hi ,

Can any one guide me how to create a file Explorer in winforms


My requirement is i want a tree view to display all the directortes in the directories in the system and on clicking the particular folder in the tree view i want to display all the text files with size and date in the list view including the icons .

Can any one guide me how to do this.

Thanks in Advance.

Thanks and Regards,
Aditya Kiran M.

推荐答案

我建​​议您先查看System.IO命名空间,该命名空间特别引用File和Directory类. Directory类的静态方法包括GetDirectories(将返回您指定目录的顶级或所有子目录),以及GetFiles,其将返回目录的所有文件名.在这两个函数之间,编写一个循环只需将子目录添加到树形视图中,然后单击目录时,只需使用GetFiles并过滤要添加列表视图的那些,就应该非常简单.您还可以通过以下方式使用FileInfo类来获取有关文件的更多信息:new FileInfo(Filename),它可以告诉您诸如文件扩展名,文件大小,创建日期等信息.

希望这会有所帮助,

埃德:)
I would suggest you start by looking at the System.IO namespace with specific reference to the File and Directory classes. The static methods of the Directory class include GetDirectories (which will return top level or all sub directories of a directory you specify) and also GetFiles which will return all the file names of a directory. Between these two functions it should be pretty simple to write a loop that just loops through sub directories adding them to a tree view and then on clicking a directory simply use GetFiles and filter which ones you add the a list view. You can also use the FileInfo class to get more information about a file by: new FileInfo(Filename) which can tell you things like file extension, file size, created date etc.

Hope this helps,

Ed :)


这篇关于Winforms中的文件资源管理器或浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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