使用Recrusion扫描整个HDD?请帮忙! [英] Scan Entire HDD With Recrusion? PLEASE HELP!

查看:59
本文介绍了使用Recrusion扫描整个HDD?请帮忙!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以提供一个示例,说明如何使用对冲搜索整个计算机吗?......

我的扫描仪通过使用加载到资源中的文本文件来扫描名称,但是当前它仅扫描组合框中选择的目录的一级.当用户从组合框中选择根目录时,如何使用对冲来扫描C:\或D:\或E:\的子​​文件夹?

我在所有地方都只能找到部分示例的情况下,此时会得到任何建议,我需要一个完整的示例,也许还需要一个简短的说明来学习推斥的步骤.

Can someone please provide an example on how to search your entire computer by using recrusion?......

My scanner scans names by using a text file loaded into the resource but currently it only scans one level of the directory selected in the combobox. How can I use recrusion to scan the subfolders of C:\ or D:\ or E:\ when the user selects the root dir from the combobox?

any advice at this point will be appriaciated as I have looked every where to only find partial examples, I need a full example and maybe a small discription to learn the steps of recrusion.

推荐答案

我认为我不需要在此处提供任何实际代码,但是步骤如下:

I don''t think I need to provide any actual code here but the steps go like this:

void RecurseFolder( scan_folder )
{
  for each file in the scan_folder
  {
    //Do whatever you need
  }

  for each new_folder in the scan_folder
  {
    //Call ourself with the new folder
    RecurseFolder( new_folder )
  }
}



您会看到该函数针对它在根文件夹中找到的每个子文件夹再次调用自身,因此它基本上以深度优先搜索的方式遍历所有目录.

如果您从未对递归进行任何操作,直到我了解它似乎有点令人困惑,但它确实非常简单.



You see the function calls itself again for each sub folder it finds in the root folder, so it works its way through all of your directories in basically a depth first search.

If you''ve never done anything with recursion before I understand that it can seem a little confusing but it''s really quite simple.


这篇关于使用Recrusion扫描整个HDD?请帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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