System.IOUtils.TPath.GetHomePath

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class function GetHomePath: string; static;

C++

static System::UnicodeString __fastcall GetHomePath();

Properties

Type Visibility Source Unit Parent
function public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils TPath

Description

Returns either the home path of the user or the application's writable scratch directory or storage. Call GetHomePath to obtain the user's home path on the supported target platforms.

If the system running your application does not support the requested folder, or if the requested folder does not exist in the system, this function returns an empty string instead.

You should use GetHomePath to store settings per user. For example:

TFile.WriteAllText(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'sample.txt', 'This is my sample text.');

GetHomePath points to the following locations on the various platforms:

  • On Windows, it points to the user’s application data folder.
  • On Linux and OS X, it points to the user’s home folder, as defined by the $(HOME) environment variable.
  • On iOS and Android, it points to the device-specific location of the sandbox for the application; the iOS home location is individually defined for each application instance and for each iOS device.
Platform Sample path Path ID
Windows XP C:\Documents and Settings\<username>\Application Data CSIDL_APPDATA
Windows Vista or later C:\Users\<username>\AppData\Roaming FOLDERID_RoamingAppData
OS X /Users/<username> NSUserDirectory
iOS Device /private/var/mobile/Containers/Data/Application/<application ID>
iOS Simulator /Users/<username>/Library/Developer/CoreSimulator/Devices/<Device ID>/data/Containers/Data/Application/<application ID>
Android /data/data/<application ID>/files Context.getFilesDir
Linux /home/<username> Home Folder

See Also