The Firemonkey provides a cross-platform function tpath.getdownloadspath to get the download directory for the platform, but strangely enough, under the Windows platform, the downloaded directory is:
C:\users\<username>\appdata\local (Official document)
Instead of
C:\users\<username>\downloads
Maybe EMB is thinking about the App sandbox approach, but what if you want to get the C:\users\<username>\downloads directory?
You can extend the Tpath function as follows:
UnitSystem.IOUtils.Helper;Interfaceuses {$IFDEF mswindows}winapi.windows, Winapi.shlobj, Winapi.knownfolders,{$ENDIF}system.ioutils;typeTpathhelper=RecordHelper forTpathclass functionGetwindownloadspath:string; static; End;Implementationclass functionTpathhelper.getwindownloadspath:string;{$IFDEF mswindows}varPath:pwidechar;begin ifSucceeded (Shgetknownfolderpath (Folderid_downloads,0,0, Path)) ThenResult:=String (Path)ElseResult: ="';End;{$ELSE}beginResult:="';End;{$ENDIF}End.
How to use:
uses System.IOUtils.Helper; var downloadpsth:string; begin downloadpath:= Tpath.getwindownloadspath; End;
function Delphi FMX Windows Get download directory