有没有一种更快的列出文件夹和子文件夹的方法? [英] Is there a quicker way to list folders and subfolders?

查看:75
本文介绍了有没有一种更快的列出文件夹和子文件夹的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我一直在对自己的问题提出错误的问题.我现在了解到,在将MD5哈希与当前文件目录进行比较时,必须使用某种类型的列表框或列表视图.我想知道是否存在使用API​​或其他函数在上述对象中填充目录内容的更快方法?


最好采用任何建议,在此先感谢您,对于由于我的不熟练而引起的任何误导性问题,我们深表歉意.

Currently I have been asking the wrong questions to my problems. I now understand that I must use some sort of listbox or listview ect when comparing MD5 hash to my current file directory Maybe true maybe not. I am interested in knowing if there is a quicker way to populate a directories contents in the above objects by using API or some other function?


any advice is well appricated thank you in advance and sorry for any misleading questions due to my inexpierence.

推荐答案

我们在这里讨论了多少文件?您现在怎么样? System.IO命名空间包含您需要的内容.

How many files are we talking about here? How are you doing it right now? The System.IO name space contains the stuff you need.

DirectoryInfo info = new DirectoryInfo(myPath);
FileSystemInfo[] infos = info.GetFileSystemInfos("*.*", true);



该代码将获取命名路径(myPath)内的所有文件(在所有子文件夹中).将检索到的信息放入ListBox很简单.



That code will get all files (in all sub-folders) inside the named path(myPath). Putting the retrieved info into a ListBox is trivial.


可能是我过去的回答会给你一个主意:
另外,请注意:如果您尝试一次从某个非常大的目录中一次获取所有目录树,则即使没有任何UI演示,您也可以简单地耗尽内存-磁盘大于RAM!

很抱歉,如果它不是很相关:很遗憾,您没有就最终目标和标准分享足够的细节(我记得您分享了一些细节,但我仍然看不清您的设计思想).

—SA
May be my past answer will give you the idea: Need Some Expert Help With Treeview Scan Please[^]?

The answer is about the tree view, but think of it as an idea. In UI, you usually don''t need to see all sub-directories at once. If so, you don''t have to scan and load them all at once. You can only fetch the file structure data about the views currently presented on-screen. In this case, the time required to fetch all data per request can be short enough.

Even though the total time of fetching file information becomes longer (because the some portion of data is repeated again and again per each user request), the user experience is more important; few extra milliseconds per click on some UI control is not noticeable.

Even if you use a list instead of tree view, you still can use the same idea: you can have Next/Previous controls to show only partial data every time.

Also, mind you: if your try to get all directory tree at once from some really big directories, you can simply deplete you memory, even without any UI presentation — disks are bigger than RAM!

Sorry if it is not very relevant: unfortunately you didn''t share enough detail on you ultimate goals and criteria (I remember you shared some, but I still cannot clearly see your design ideas).

—SA


希望
Hope this[^] might help you.


这篇关于有没有一种更快的列出文件夹和子文件夹的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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