how get file properties with Firemonkey

≡放荡痞女 提交于 2020-01-14 05:45:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!