[英]Incorrectly returning empty file list on Android with Delphi 10
I want to create a list of log files from my system, but the GetFiles
function returns empty on Android, even though there are several files in the folder (on Windows works). 我想从我的系统创建一个日志文件列表,但GetFiles
函数在Android上返回空,即使该文件夹中有多个文件(在Windows上工作)。 I can't identify anything wrong or missing. 我无法识别任何错误或遗漏。 Does anyone know what might be happening? 有谁知道可能会发生什么? NOTE: Tests made on Android 4.4, Delphi 10.2.1, Windows 10 注意:在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;
You've used a \\
as the path separator. 您已使用\\
作为路径分隔符。 It's /
on Android. 这是/
在Android上。 But don't hardcode it, let TPath.Combine
do the platform sensitive work for you. 但是不要硬编码,让TPath.Combine
为您做平台敏感的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.