Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by cagefree · Dec 08, 2010 at 10:00 PM · filesystemdirectory

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aubrey-Falconer · Dec 10, 2010 at 01:20 AM 1
Share

I have the same problem, and haven't yet found a better solution. Here's a forum thread which arrives at the same conclusion as well: http://forum.unity3d.com/threads/23686-SOLVED-Special-folder-path-in-mac Wish you the best of luck in finding a more elegant solution!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Nicolaj Schweitz · Dec 27, 2010 at 05:17 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aubrey-Falconer · Dec 27, 2010 at 08:47 PM 0
Share

Thanks - but on my $$anonymous$$acbook Pro running snow leopard, SpecialFolder.ApplicationData, SpecialFolder.LocalApplicationData, and SpecialFolder.Personal (the best options on the page you linked) return /Users/Ad$$anonymous$$/.Config, /Users/Ad$$anonymous$$/.local/share, and /Users/Ad$$anonymous$$/Documents, respectively. I guess there is no elegant way to achieve this.

avatar image cagefree · Jan 09, 2011 at 11:15 PM 0
Share

Yes, appreciate the attempt but it's not really an answer to my question. I'm not quite sure what you are implying with this answer -- don't use those functions because we have no control over mono? Or, here is what mono does with that, use it with that in $$anonymous$$d? If there isn't a consistent clean cross-platform way to get this folder then it would be nice if Unity provided something directly.

avatar image
0

Answer by Andres Martinez · Sep 06, 2011 at 11:46 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Accessing local system ( File Browser ) 2 Answers

Creating a Directory in "My Documents" 2 Answers

How to save a file while connected to a server in the right dircetory 0 Answers

Visual Studio tells me I cant use File.WriteAllBytes or System.IO.File.WriteAllBytes? 1 Answer

How do I load a config (.cfg) or ini file? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges