如何使用Firemonkey获取文件属性

时间:2018-10-24 00:40:39

标签: firemonkey c++builder

使用TDirectory类(reference here)的GetFiles方法,我可以使用下面的C ++ Builder代码在我的apps文档文件夹中列出文件(适用于移动设备和台式机)。

现在,如何获取有关文件的详细信息,例如大小,日期等?

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);

0 个答案:

没有答案