问题
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);
来源:https://stackoverflow.com/questions/52959589/how-get-file-properties-with-firemonkey