There are several possible ways of getting the path to the application data directory:

  • using the %APPDATA% environment variable
  • calling SHGetFolderPath 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?

Edit
Report