使用Delphi 10在Android上错误地返回空文件列表

wBB*_*wBB 2 delphi android firemonkey

我想从我的系统创建一个日志文件列表,但该GetFiles函数在Android上返回空,即使该文件夹中有多个文件(在Windows上也可以).我无法识别任何错误或遗漏.有谁知道可能会发生什么?注意:在Android 4.4,Delphi 10.2.1,Windows 10上进行的测试

var LList: TStringDynArray;
const
  ROOT_FOLDER = 'AAA';
  LOG_FOLDER = 'BBB';
begin
  LList := TDirectory.GetFiles(
    System.IOUtils.TPath.Combine(
      System.IOUtils.TPath.GetDocumentsPath, ROOT_FOLDER + '\' + LOG_FOLDER));
  ShowMessage(IntToStr(Length(LList)));  // returns zero!!
end;
Run Code Online (Sandbox Code Playgroud)

Dav*_*nan 7

您已使用a \作为路径分隔符.它/在Android上.但是不要硬编码,让TPath.Combine平台敏感的工作为你做.