I need to get a safe temp folder where I can store temporary files for my application, but so far my research has led me to conclude that all the approaches that I found are wrong.
The first idea was to use the GetTempPath function, but this causes two problems:
- The folder may not exist, so I will have to crop the folders one by one to the root and recreate them if they do not exist back to the full path (error prone, tedious)
- From the "Larry Osterman WebLog" click , it seems that
GetTempPath can fall back to USERPROFILE or the Windows directory and extract a whole series of files right there, which is SUPER BAD (TM)!
In the same post there is a suggestion to use GetEnvironmentVariable, but this seems to me a dangerous function (for example, there are no TMP and TEMP envvars).
Is there a cleaning function that I could use? It seems that SHGetKnownFolderPath does not know what the temporary folder is.
source share