function Delphi FMX Windows Get download directory

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.