The problem is that ArcMap is changing it's runtime environment (the TEMP
and TMP
environment variables) to create a unique temp folder for each run. Any Windows API call to retrieve the temp folder will return the updated ones (by design).
One thing I would like to do is store data in the users temporary folder.
I would recommend storing the data within the user's application data folder instead. This is an appropriate place to store user data, and will be consistent. Try something like:
var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
path = Path.Combine(path, @"YourCompany\YourProduct\");