如何递归检查文件夹及其子文件夹 [英] How to recursively check folder and its subfolder

查看:70
本文介绍了如何递归检查文件夹及其子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我在C驱动器中有一个文件夹,其名称已根据今天的日期保存.它里面有很多子文件夹.每个子文件夹再次包含文件夹和文本文件.现在,我想在C驱动器中提取根据今天的日期保存的文件夹,并检查该日期文件夹中的所有子文件夹并读取其中的所有文本文件.
谁能帮助我.

Hello,
I have one folder in C drive, whose name is saved according to today date. It has many sub folder inside. Each sub folder contains again folder and text files.Now i want to pickup folder inside C drive which is saved according to today date and check all subfolder inside that date folder and read all text files in it.
Can anyone please help me.

推荐答案

public void FindFiles(string startDir, string fileName)
       {


           if (Directory.Exists(startDir))
           {
             string[] files = Directory.GetFiles(startDir,      fileName,SearchOption.AllDirectories);

               if (files.Length > 0)
               {
                   foreach (string file in files)
                   {
                       resultsList.Items.Add(file);//Add to a Listview or whatever
                   }


               }
           }


       }


这篇关于如何递归检查文件夹及其子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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