There are several possible ways of getting the path to the application data directory:
%APPDATA%
environment variableSHGetFolderPath
with CSIDL_APPDATA
What is the best way to get the path from within an program? Are there any gotchas when I use the environment variable?
Which method is safest across XP, Vista and upcoming versions?
AppData is a hidden folder located in C:\Users\<username>\AppData.
Direct access Tap the Win+R keyboard shortcut to open the run box. In the run box, enter %AppData% , and tap the Enter key. A new File Explorer window will open to the AppData's Roaming folder. Click the 'AppData' folder in the location bar to go to the main AppData folder.
Unfortunately you cannot move AppData folder to another drive. Moving AppData folder to another drive might cause system stability. AppData or Application data is a hidden folder in Windows 8/8.1. It is to protect user data and settings from any unwanted change or deletion.
I would suggest that calling SHGetFolderPath()
is the most appropriate, and portable method; the alternatives, such as reading an environment variable, or (worse) trying to extract it from the registry are likely to trip you up in the future.
Raymond Chen has an article explaining why pulling such paths from the registry is a bad idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With