Show: Object Pascal C++
Display Preferences


From Appmethod Libraries
Jump to: navigation, search

Object Pascal

class function GetHomePath: string; static;


static System::UnicodeString __fastcall GetHomePath();


Type Visibility Source Unit Parent
function public
System.IOUtils TPath


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 Mac 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
Mac 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

See Also

Personal tools