[Mono-list] How to get user's HOME directory

Stefan Saring stefan.saring@epost.de
04 Apr 2003 23:34:55 +0200


I know that the name of the home directory can differ on Win32 systems,
it was only an example.

I agree with you, that this would be the best way:
Environment.GetFolderPath (Environment.SpecialFolder.Personal);

But it does not work (Linux, mono 0.23) and most of the other
SpecialFolder constants does not work too. Could be a bug or the mono
people don't want to port it, because it's too Win32 specific.

Regards,
Stefan

Am Fre, 2003-04-04 um 23.22 schrieb Piers Haken:
> > -----Original Message-----
> > From: Stefan Saring [mailto:stefan.saring@epost.de] 
> > Sent: Thursday, April 03, 2003 10:54 PM
> > To: Marcus
> > Cc: mono-list@lists.ximian.com
> > Subject: Re: [Mono-list] How to get user's HOME directory
> > 
> > 
> > Yes. On Windows2000 it's e.g. "C:\Documents and 
> > Settings\USERNAME\". This is the place where many 
> > applications store their user settings and profiles (e.g. Mozilla).
> 
> This isn't necessarily true. Firstly the directory may not be on the
> 'C:' drive. Secondly, the string 'Documents and Settings' can be
> localized. And thirdly the subdirectory may not be the same as the
> username. If for any reason the directory exists (dual-boot,
> domain/local) then windows setup will pick a new name. In general, you
> shouldn't make assumptions about folder names in the user's profile, you
> should use the Environment.SPecialFolder enumeration instead.
> 
> Piers.
-- 
Stefan Saring <stefan.saring@epost.de>