Jump to content

Search the Community

Showing results for tags 'getfiles'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. In Delphi 10.4, I was able to get a listing of files in an Android 11 device's shared storage. In Delphi 11.2, with necessary permission set (either programmatically or on the device), TDirectory.GetFiles() is returning an empty list (ie. zero entries). TDirectory.GetDirectories() is working correctly, and using TFile.Exists() with a filename which I know to be present returns true. But, if I try to open that file with, for instance, TFile.ReadAllText(), access is denied. Any suggestions? This is an example program which fails in Delphi 11.2: unit test11main; interface uses System.Types,System.Classes,system.sysUtils,system.IOUtils,system.Permissions, {$IFDEF ANDROID} Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os, {$ENDIF} FMX.Types,FMX.Forms,FMX.Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private fOK:boolean; procedure PermissionsResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray); end; var Form1: TForm1; implementation {$R *.fmx} procedure Tform1.PermissionsResult(Sender: TObject; const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray); var n:integer; begin if length(AGrantResults)>0 then for n:=0 to length(AGrantResults)-1 do if not (AGrantResults[n] = TPermissionStatus.Granted) then fOK:=false; end; procedure TForm1.FormCreate(Sender: TObject); var DataDir:string; p:Tarray<string>; LList: TStringDynArray; begin fOK:=true; { if I omit the next two lines and manually set permissions on the Android device it still does not work} p:=[JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE), JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)]; PermissionsService.RequestPermissions(p,PermissionsResult,nil); if fOK then begin DataDir := TPath.GetSharedDocumentsPath; showmessage(DataDir); //correctly displays /storage/emulated/0/Documents Llist:=Tdirectory.GetFiles(DataDir); showmessage(inttostr(length(Llist))); //returns zero when run in Delphi 11.2 end else showmessage('permission refused'); end; end.
×