Bug 41258 - Environment.SpecialFolder.MyDocuments is wrong on OS X
Summary: Environment.SpecialFolder.MyDocuments is wrong on OS X
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2016-05-23 16:22 UTC by Norbert Virth
Modified: 2017-10-12 12:25 UTC (History)
8 users (show)

Is this bug a regression?: ---
Last known good build:

Version info provided by Xamarin Studio (974 bytes, text/plain)
2016-05-23 16:22 UTC, Norbert Virth

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 41258 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Norbert Virth 2016-05-23 16:22:29 UTC
Created attachment 16073 [details]
Version info provided by Xamarin Studio

This code:

    var myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

will return the same as if called with Environment.SpecialFolder.UserProfile on OS X
So "/Users/username", instead of "/Users/username/Documents" (on a mac with language EN)
Comment 1 Chris Hamons 2016-05-23 16:52:33 UTC
The code in question is here:

Comment 2 Marek Safar 2016-05-25 07:50:21 UTC
This is by design.

Unfortunately SpecialFolder.Personal has same value as SpecialFolder.MyDocuments so we cannot easily distinguish between them hence we return /Users/username which sort of fits to both of them.
Comment 3 Norbert Virth 2016-05-25 09:19:02 UTC
A workaround then. The link below is for iOS, but it worked for me on OS X 10.10 as well:


And the code based on the link which makes it:

var myDocumentsDir = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].Path;
Comment 4 Aaron Bockover [MSFT] 2016-05-26 03:32:58 UTC
Norbert is correct. We are treating Personal and MyDocument the same as UserProfile.

From the RS definition of SpecialFolder:

  UserProfile = Win32Native.CSIDL_PROFILE
  Personal = Win32Native.CSIDL_PERSONAL
  MyDocuments = Win32Native.CSIDL_PERSONAL

And if we look at the CSIDL definitions:

  CSIDL_PROFILE:  The user's profile folder. A typical path is C:\Users\username.
  CSIDL_PERSONAL: The virtual folder that represents the My Documents desktop item. This is equivalent to CSIDL_MYDOCUMENTS. A typical path is C:\Documents and Settings\username\My Documents.

So yes, Personal and MyDocuments are the same, but we've been treating Personal as UserProfile, which is a bug in Mono on Mac.

So on a Mac it should be (and if not the paths below, whatever blessed NSFileManager API makes sense, as Norbert points out):

  UserProfile → $HOME
  Personal → $HOME/Documents
  MyDocuments → $HOME/Documents
Comment 6 Marek Safar 2017-10-12 12:25:18 UTC
We could try to change Personal/MyDocuments case with some fall-back option to old behaviour