#include <System.Ioutils.hpp>
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Disk_And_Directory_Support_Routines
获得文件清单,文件列表,递归子目录
void __fastcall TForm1::Button1Click(TObject *Sender) { TStringDynArray list; TSearchOption searchOption; /* Select the search option */ if (cbDoRecursive->Checked) searchOption = TSearchOption::soAllDirectories; else searchOption = TSearchOption::soTopDirectoryOnly; try { /* For all entries use GetFileSystemEntries method */ if (cbIncludeDirectories->Checked && cbIncludeFiles->Checked) list = TDirectory::GetFileSystemEntries(edtPath->Text, searchOption, NULL); /* For directories use GetDirectories method */ if (cbIncludeDirectories->Checked && !cbIncludeFiles->Checked) list = TDirectory::GetDirectories(edtPath->Text, edtFileMask->Text, searchOption); /* For files use GetFiles method */ if (!cbIncludeDirectories->Checked && cbIncludeFiles->Checked) list = TDirectory::GetFiles(edtPath->Text, edtFileMask->Text, searchOption); } catch (...) { /* Catch the possible exceptions */ MessageDlg("Incorrect path or search mask", mtError, TMsgDlgButtons() << mbOK, 0); return; } /* Populate the memo with the results */ mmResults->Clear(); for (int i = 0; i < list.Length; i++) mmResults->Lines->Add(list[i]); }