0

Using the GetFiles method of the TDirectory class (reference here) I can list files in my apps documents folder with the C++ Builder code below (works on mobile and desktop).

Now, how can I also get details about the files such as size, date etc.?

TStringDynArray list;
TSearchOption searchOption;
UnicodeString DocsPath;
int lenDocsFolder;

DocsPath = System::Ioutils::TPath::GetDocumentsPath();
lenDocsFolder = DocsPath.Length();

searchOption = TSearchOption::soTopDirectoryOnly;
try
{
    /* For files use GetFiles method */
  list = TDirectory::GetFiles(DocsPath, "*.*", searchOption);
}
catch (...)
{
    /* Catch the possible exceptions */
    ShowMessage("Incorrect path or search mask");
    return;
}
UnicodeString mylist;
for (int i = 0; i < list.Length; i++)
 {
    list[i] = list[i].Delete0(0, lenDocsFolder+1);  // trim off the path so looks clean
    mylist = mylist + list[i] + "\n";
 }
 mylist = mylist + "\n" + "Files from: " + DocsPath;
 ShowMessage(mylist);
relayman357
  • 793
  • 1
  • 6
  • 30
  • 1
    Look at things like `SysUtils.FindFirst()`, `System.IOUtils.TFile`, etc – Remy Lebeau Oct 25 '18 at 01:44
  • Thanks Remy! This is nice starting point: [link](http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/SysUtils_FindFirst.html) – relayman357 Oct 25 '18 at 15:13

0 Answers0