0
我们有一个Android应用程序,并在DocumentsPath我们有一个叫做“默认”如何在Android FireMonkey应用程序中获取(子)目录?
然而,当我们检索来自DocumentsPath目录子文件夹,该文件夹显示不出来。
有没有人知道该怎么做?
的代码如下:
procedure TdmoMain.SetupDirArray;
var
mDirs: TStringDynArray;
begin
RootDir := TPath.GetDocumentsPath;
{$if defined(MSWINDOWS)}
mDirs:=TDirectory.GetDirectories(RootDir, '[!_]*'); //on Windows no directories which start with '_'
{$ELSE}
mDirs:=TDirectory.GetDirectories(RootDir);
{$ENDIF}
if High(mDirs)>0 then //this should be always true BUT IT IS NOT (IOW at least one subdir - album installed)
begin
SetHomeDir; //do some processing here
end
else //unfortunately it goes here
begin
{ DEBUG CODE BEGIN }
SetLength(mDirs, 1);
mDirs[0]:=TPath.Combine(RootDir, 'default');
if TDirectory.Exists(mDirs[0]) then
ShowMessage('Puzzled!'); //this shows up!!!
{ DEBUG CODE END }
// ShowMessage('You do not have any subdirectories!');
end;
end;
我们采用Delphi XE6。
你确定'default'是一个目录,而不是某个虚拟位置或符号链接等? 我不是android高级用户或开发人员,只是猜测。如果TDirectory说它不存在,那么它可能真的没有,它不是目录? – teran 2014-09-26 10:42:26
@teran:我敢肯定。它由Delphi的部署引擎创建,并且里面有文件。如果我做TDirectory.GetFiles(RootDir +'默认'),我甚至可以通过安装(一些jpeg,一个ini,一个SQLite数据库等)来检索我放入的文件。 – 2014-09-26 14:50:28
做一些调试。为什么该函数返回false。跟踪它。 – 2014-09-26 21:38:24