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