Show / Hide Table of Contents

Class folders

Gets known/special folder paths (Desktop, Temp, etc).

public static class folders
Remarks

Most functions return FolderPath, not string. It is implicitly convertible to string. Its operator + appends a filename or relative path string, with \ separator if need. Example:

string s = folders.Desktop + "file.txt"; //C:\Users\Name\Desktop\file.txt

If a function cannot get folder path, the return value contains null string. Then the + operator would throw ArgumentException.

Some folders are known only on newer Windows versions or only on some computers. Some functions have a suffix like _Win8 which means that the folder is unavailable on older Windows. Some known folders, although supported and registered, may be still not created.

Some folders are virtual, for example Control Panel. They don't have a file system path, but can be identified by a data structure ITEMIDLIST. Functions of the nested class folders.shell return it as Pidl or string ":: ITEMIDLIST" that can be used with some functions of this library (run.it, icon.of, icon.ofPidl) but not with .NET functions.

Most functions use Windows "Known Folders" API, such as SHGetKnownFolderPath. The list of Windows predefined known folders: KNOWNFOLDERID. Names of folders specific to current process have prefix This, like ThisApp.

Some paths depend on the bitness (32 or 64 bit) of the OS and this process.

32-bit Windows System, SystemX86, SystemX64: @"C:\WINDOWS\system32"
ProgramFiles, ProgramFilesX86, ProgramFilesX64: @"C:\Program Files"
ProgramFilesCommon, ProgramFilesCommonX86, ProgramFilesCommonX64: @"C:\Program Files\Common Files"
64-bit Windows, 64-bit process System, SystemX64: @"C:\WINDOWS\system32"
SystemX86: @"C:\WINDOWS\SysWOW64"
ProgramFiles, ProgramFilesX64: @"C:\Program Files"
ProgramFilesX86: @"C:\Program Files (x86)"
ProgramFilesCommon, ProgramFilesCommonX64: @"C:\Program Files\Common Files"
ProgramFilesCommonX86: @"C:\Program Files (x86)\Common Files"
64-bit Windows, 32-bit process System: @"C:\WINDOWS\system32". However the OS in most cases redirects this path to @"C:\WINDOWS\SysWOW64".
SystemX86: @"C:\WINDOWS\SysWOW64"
SystemX64: @"C:\WINDOWS\Sysnative". The OS redirects it to the true @"C:\WINDOWS\system32". It is a special path, not in Explorer.
ProgramFiles, ProgramFilesX86: @"C:\Program Files (x86)"
ProgramFilesX64: @"C:\Program Files"
ProgramFilesCommon, ProgramFilesCommonX86: @"C:\Program Files (x86)\Common Files"
ProgramFilesCommonX64: @"C:\Program Files\Common Files"

Namespace: Au
Assembly: Au.dll
Inheritance
object
folders

Properties

Name Description
AccountPictures_Win8
AdminTools
ApplicationShortcuts_Win8
CDBurning
CameraRoll_Win81
CdDvdDrive

Gets CD/DVD drive path, like @"D:\".

CommonAdminTools
CommonOEMLinks
CommonPrograms
CommonStartMenu
CommonStartup
CommonTemplates
Contacts
Cookies
Desktop
DeviceMetadataStore
Documents
DocumentsLibrary
Downloads
Editor

Gets folder of the script editor. Available in the script editor process and in scripts launched from it. Elsewhere null.

Favorites
Fonts
GameTasks
History
ImplicitAppShortcuts
InternetCache
Libraries
Links
LocalAppData
LocalAppDataLow
LocalizedResourcesDir
Music
MusicLibrary
NetHood
NetRuntime

Gets .NET runtime folder, like C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6.

NetRuntimeBS

Gets .NET runtime folder with '\\' at the end, like C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\.

NetRuntimeDesktop

Gets .NET runtime desktop folder, like C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6.

NetRuntimeDesktopBS

Gets .NET runtime desktop folder with '\\' at the end, like C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\.

OriginalImages
PhotoAlbums
Pictures
PicturesLibrary
Playlists
PrintHood
Profile
ProgramData
ProgramFiles

More info in class help.

ProgramFilesCommon

More info in class help.

ProgramFilesCommonX64

More info in class help.

ProgramFilesCommonX86

More info in class help.

ProgramFilesX64

More info in class help.

ProgramFilesX86

More info in class help.

Programs
Public
PublicDesktop
PublicDocuments
PublicDownloads
PublicGameTasks
PublicLibraries
PublicMusic
PublicPictures
PublicRingtones
PublicUserTiles_Win8
PublicVideos
QuickLaunch
Recent
RecordedTV
RemovableDrive0

Calls folders.removableDrive(0).

RemovableDrive1

Calls folders.removableDrive(1).

RemovableDrive2

Calls folders.removableDrive(2).

RemovableDrive3

Calls folders.removableDrive(3).

ResourceDir
Ringtones
RoamedTileImages_Win8
RoamingAppData
RoamingTiles_Win8
SampleMusic
SamplePictures
SamplePlaylists
SampleVideos
SavedGames
SavedPictures
SavedPicturesLibrary
SavedSearches
Screenshots_Win8
SearchHistory_Win81
SearchTemplates_Win81
SendTo
SidebarDefaultParts
SidebarParts
SkyDriveCameraRoll_Win81
SkyDriveDocuments_Win81
SkyDrivePictures_Win81
SkyDrive_Win81
StartMenu
Startup
System

More info in class help.

SystemX64

Gets non-redirected path of the System32 folder.

SystemX86

More info in class help.

Temp

Temp folder (temporary files) of this user account.

Templates
ThisApp

Folder containing assemblies of this app.

ThisAppBS

folders.ThisApp with appended backslash character.

ThisAppDataCommon

Gets or sets path of folder "common (all users) private files of this application".

ThisAppDataLocal

Gets or sets path of folder "local (non-roaming) private files of this application of this user account".

ThisAppDataRoaming

Gets or sets path of folder "roaming private files of this application of this user account".

ThisAppDocuments

Gets or sets path of folder "user document files of this application".

ThisAppDriveBS

Gets the root directory of this application, like @"C:\" or @"\\server\share\".

ThisAppImages

Gets or sets path of folder "images of this application".

ThisAppTemp

Gets or sets path of folder "temporary files of this application".

TreeProperties
UserProfiles
UserProgramFiles
UserProgramFilesCommon
Videos
VideosLibrary
Windows
Workspace

Gets folder of current workspace. Available in the script editor process and in scripts launched from it. Elsewhere null.

WorkspaceDriveBS

Gets the root directory of folders.Workspace, like @"C:\" or @"\\server\share\".

noAutoCreate

Don't auto-create folders when accessing folders.ThisAppDocuments, folders.ThisAppTemp, folders.ThisAppDataLocal or folders.ThisAppDataRoaming in this thread.

Methods

Name Description
envVar(string)

Gets the value of an environment variable in current process.

getFolder(string)

Gets path of a known folder by its name.

getKnownFolders()

Gets canonical names and paths of all known folders, including custom known folders registered by applications. These names can be used with folders.getFolder.

removableDrive(int)

Gets removable/external/USB drive path, like @"F:\".

removableDrive(string)

Gets removable/external/USB drive name (like @"F:\") by its volume label.

sourceCode(string)

Gets folder path of the caller source code file.

sourceCodeMain(Assembly)

Gets folder path of the main source code file of this program or of a library.

unexpandPath(string)

If string starts with a known/special folder path, replaces that part with %folders.FolderName%. Else returns unchanged string. For example if string is "C:\Windows\System32\notepad.exe", returns "%folders.System%\notepad.exe".

unexpandPath(string, out string, out string)

If string starts with a known/special folder path, gets folder name + relative path and returns true. For example if string is "C:\Windows\System32\notepad.exe", gets "folders.System" and "notepad.exe".

unexpandPath(string, params (string folder, string replacement)[])

If path starts with one of specified folder paths, replaces that part with the replacements string. Else returns unchanged string.