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

Stefan Saring stefan.saring@epost.de
04 Apr 2003 19:59:32 +0200


Thanks for all the hints. So it seems there's no proper way to get the
user home directory with mono. But this workaround works fine:

public string GetUserHomeDirectory ()
{
    if ((Environment.OSVersion.Platform == PlatformID.Win32S) ||
        (Environment.OSVersion.Platform == PlatformID.Win32Windows) ||
        (Environment.OSVersion.Platform == PlatformID.Win32NT))
    {
        return Environment.GetEnvironmentVariable ("USERPROFILE");
    }
    else {
        return Environment.GetEnvironmentVariable ("HOME");
    }
}

Bye,
Stefan
-- 
Stefan Saring <stefan.saring@epost.de>