Windows System¶
AppDirs Instance Methods¶
In a Windows machine, following AppDirs
methods point at the directories
below:
val appDirs: AppDirs = AppDirsFactory.getInstance() val APP_NAME = "myApp" val APP_VERSION = "0.1.0" val APP_AUTHOR = "myName" // or the organization name val userLocalDataDir: Path = appDirs.getUserDataDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\Users\<username>\AppData\Local\myName\myApp\0.1.0 val userRoamingDataDir: Path = appDirs.getUserDataDir(APP_NAME, APP_VERSION, APP_AUTHOR, roaming = true) // C:\Users\<username>\AppData\Roaming\myName\myApp\0.1.0 val userLocalConfigDir: Path = appDirs.getUserConfigDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\Users\<username>\AppData\Local\myName\myApp\0.1.0 val userRoamingConfigDir: Path = appDirs.getUserConfigDir(APP_NAME, APP_VERSION, APP_AUTHOR, roaming = true) // C:\Users\<username>\AppData\Roaming\myName\myApp\0.1.0 val userCacheDir: Path = appDirs.getUserCacheDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\Users\<username>\AppData\Local\myName\myApp\Cache\0.1.0 val userDownloadsDir: Path = appDirs.getUserDownloadsDir() // C:\Users\<username>\Downloads val userDesktopDir: Path = appDirs.getUserDesktopDir() // C:\Users\<username>\Desktop val userDocumentsDir: Path = appDirs.getUserDocumentsDir() // C:\Users\<username>\My Documents val userMusicDir: Path = appDirs.getUserMusicDir() // C:\Users\<username>\My Music val userPicturesDir: Path = appDirs.getUserPicturesDir() // C:\Users\<username>\My Pictures val userVideosDir: Path = appDirs.getUserVideosDir() // C:\Users\<username>\My Videos val userLogDir: Path = appDirs.getUserLogDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\Users\<username>\AppData\Local\myName\myApp\Logs\0.1.0 val siteDataDir: Path = appDirs.getSiteDataDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\ProgramData\myName\myApp\0.1.0 val siteConfigDir: Path = appdirs.getSiteConfigDir(APP_NAME, APP_VERSION, APP_AUTHOR) // C:\ProgramData\myName\myApp\0.1.0
Notes
getUserDataDir
andgetUserConfigDir
withoutroaming
or withroaming
isfalse
point at the same directory. (SeeuserLocalDataDir
anduserLocalConfigDir
above.)getUserDataDir
andgetUserConfigDir
withroaming
istrue
point at the same directory. (SeeuserRoamingDataDir
anduserRoamingConfigDir
above.)getSiteDataDir
andgetSiteConfigDir
(with or withoutlocal
argument) point at the same directory. (SeesiteDataDir
andsiteConfigDir
above.)local
argument ongetSiteDataDir
andgetSiteConfigDir
has no effect on Windows machines.- Windows is the only system that utilizes
roaming
argument ongetUserDataDir
andgetUserConfigDir
methods. local
argument ongetSiteDataDir
andgetSiteConfigDir
has no effect in Windows system.- Windows is the only system that utilizes
appAuthor
on every method1. - Windows system is the only system that uses backward slashes (\) as the directory separator.
What is Roaming?¶
Since Windows NT 3.1, Windows system uses a concept called roaming, which moves or copies the content of the related application directory over the network to different machines.
The methods below support one extra argument called roaming
:
getUserDataDir
getUserConfigDir
With roaming
is true
, the application directory points at the roaming
application directory.
However, since this option is not widely used in Windows, it is not activated by default. To activate this feature, see this documentation of Microsoft.
This feature is especially useful for business machines that are connected to the same network.
-
appAuthor
argument, in allAppDirs
instance methods' signatures, it is marked asString?
and defaults tonull
and since it isnull
by default, you do not have to passappAuthor
. In this case,appAuthor
will not be rendered in the end result. ↩