Application Support / LocalApplicationData

I would like to have access to a persistent folder to write cache data to in my cross platform (Mac/Windows) Unity app.

My impression is that on Macs the correct folder should be

~/Library/Application Support/

and on Windows it would be something like

%USERPROFILE%\Local Settings\Application Data\

Now, it seems like there is almost a way to get this cleanly because on Windows I believe the following function returns the right location.

System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData)

Unfortunately for whatever reason it doesn't appear to return the corresponding location on Macs. So my solution was to #ifdef by platform and use this one

System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)

which for me resolves to the root of user directory (~/) and then I add the necessary subdirs onto it.

The trouble is that when I started testing my app on other Macs it ended up returning the ~/Documents directory for other users.

Is there a recommended and cleaner way to deal with all of this?

Please refer to the current* Mono documentation on this issue:

http://www.go-mono.com/docs/index.aspx?link=T:System.Environment%2bSpecialFolder

*The code is not maintained by Unity Technologies and may change without our knowledge.

If you select the API Compatibility Level as “Net 2.0” (not the Subset option), the path in a Mac is correctly identified as the user folder and not the Documents folder.