using System;
using System.Collections.Generic;
using System.IO;
private List<string> finded_files = new List<string>();
private void RecursiveGetFiles(string parent_path)
{
string[] files = Directory.GetFiles(parent_path);
foreach (string file in files)
{
// 这里可以进行文件的过滤,比如筛选指定的后缀
finded_files.Add(file);
}
string[] paths = Directory.GetDirectories(parent_path);
foreach (string path in paths)
{
RecursiveGetFiles(path);
}
}
此方法在外部声明了一个用于存储文件路径的集合,文件名称包括了完整路径。