Void getFileBydir (String DirPath, Ref ArrayList Al)
{
/ / List all files, add to Al
FOREACH (String File in Directory.GetFiles (DirPath))
Al.Add (file);
/ / List all the subfolders and call the getAllFileBydir themselves;
FOREACH (String Dir in Directory.GetDirectories (DirPath))
GetAllFileBydir (Dir, Ref Al);
}
After running this function, the Al is all files in the DirPath folder (including the subfolders);
--2011-10-12 Update
void GetAllFileByDir (string DirPath, string searchPattern, List LI_Files) {// include all files, added to AL foreach (string file in Directory.GetFiles (DirPath, searchPattern)) LI_Files.Add (file); // include There are all child folders, and call GetAllFileBydir themselves; Foreach (String Dir in Directory.Getdirectories (DirPath) getFilebyDir (Dir, searchPattern, li_files);}