How to get the %AppData% folder in C?

Use SHGetSpecialFolderPath with a CSIDL set to the desired folder (probably CSIDL_APPDATA or CSIDL_LOCAL_APPDATA).

You can also use the newer SHGetFolderPath() and SHGetKnownFolderPath() functions.
There’s also SHGetKnownFolderIDList() and if you like COM there’s IKnownFolder::GetPath().

Leave a Comment