<p>I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.</p>

<p>Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want different settings.</p>

<p>Is it C:\Documents and Settings\username\MyApp good for both Vista and XP?
Is it /home/username/.MyApp good for Linux and Macs?</p>

<p>Any ideas and/or links to best practices much appreciated.</p>

<p>Thanks!</p>

<p>Juan</p>

[{'answer_id': 57025, 'author': 'Kristopher Johnson', 'author_id': 1175, 'author_profile': 'https://Stackoverflow.com/users/1175', 'pm_score': 5, 'selected': True, 'text': "<p>Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder.  </p>\n\n<ul>\n<li>Windows: SHGetFolderPath() or SHGetKnownFolderPath()</li>\n<li>Mac OS X and iPhone OS: NSSearchPathForDirectoriesInDomains()</li>\n<li>Unix: $HOME environment variable</li>\n</ul>\n\n<p>Don't hardcode specific paths or just tack a prefix and suffix on the user's name.  Also, try to follow whatever conventions there are for the platform for naming the files.</p>\n"}, {'answer_id': 57028, 'author': 'Juan Delgado', 'author_id': 5908, 'author_profile': 'https://Stackoverflow.com/users/5908', 'pm_score': 2, 'selected': False, 'text': "<p>I'm not :) </p>\n\n<p>I'm using USERPROFILE in Windows and HOME in Mac/Linux. But even so, I need to know that those are the right places.</p>\n\n<p>Thanks!</p>\n"}, {'answer_id': 57035, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 2, 'selected': False, 'text': '<p>In windows you need to go another level deep than just the user profile.  Use the Application Data folder.</p>\n'}, {'answer_id': 57037, 'author': 'Darcy Casselman', 'author_id': 5062, 'author_profile': 'https://Stackoverflow.com/users/5062', 'pm_score': 1, 'selected': False, 'text': "<p>Never, ever store user data in the application folder.  It's just a bad idea.</p>\n\n<p>Most operating systems have a $HOME (or %HOME%) environment variable.  That would be the first place to look.  </p>\n\n<p>If you want to cleanly support multiple operating systems, though, you're going to have to have some OS-specific code for each that figures out exactly where things need to go.  (~/Library for Mac OS, ~/.config for GNOME-based systems, %HOME%/Application Data for Windows, etc.).</p>\n"}, {'answer_id': 57042, 'author': 'brian newman', 'author_id': 3210, 'author_profile': 'https://Stackoverflow.com/users/3210', 'pm_score': 2, 'selected': False, 'text': '<p>On Windows I use APPDATA,and on Linux I use HOME.</p>\n'}, {'answer_id': 57059, 'author': 'Rhett D', 'author_id': 4420, 'author_profile': 'https://Stackoverflow.com/users/4420', 'pm_score': 3, 'selected': False, 'text': '<p>In regards to best practices, Jeff posted an article on polluting user space that you might find useful: <a href="https://blog.codinghorror.com/dont-pollute-user-space/" rel="nofollow noreferrer" title="Don\'t Pollute User Space">Don\'t Pollute User Space</a></p>\n'}, {'answer_id': 57146, 'author': 'Steve Morgan', 'author_id': 5806, 'author_profile': 'https://Stackoverflow.com/users/5806', 'pm_score': 2, 'selected': False, 'text': "<p>As a general point, I'd recommend abstracting the implementation of your settings into a 'Settings Provider' and provide different providers for each platform. That way, you can implement the storage of the settings in the manner that best suits the target platforms (for example, a file on Linux or the Windows Registry).</p>\n\n<p>Don't simply adopt the 'lowest common denominator'. Where you have content that must be explicity stored in files, have your settings provider expose the platform-specific location for those files.</p>\n"}, {'answer_id': 57416, 'author': 'dsvensson', 'author_id': 5962, 'author_profile': 'https://Stackoverflow.com/users/5962', 'pm_score': 2, 'selected': False, 'text': '<p>For Linux/BSD/Solaris:\n<a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html" rel="nofollow noreferrer">http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html</a></p>\n'}, {'answer_id': 367164, 'author': 'Michael Borgwardt', 'author_id': 16883, 'author_profile': 'https://Stackoverflow.com/users/16883', 'pm_score': 1, 'selected': False, 'text': '<p>What language are you planning to use? Java, for example, has a dedicated <a href="http://java.sun.com/javase/6/docs/technotes/guides/preferences/index.html" rel="nofollow noreferrer">Preference API</a>.</p>\n'}]
['https://Stackoverflow.com/questions/57019', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5908/']