title: Getting the path of the home directory in C#?
body: <p>Okay, I've checked Environment.SpecialFolder, but there's nothing in there for this.</p>
  
  <p>I want to get the home directory of the current user in C#. (e.g. <code>c:\documents and settings\user</code> under XP, <code>c:\users\user</code> under Vista, and <code>/home/user</code> under Unix.)</p>
  
  <p>I know I can read enviroment variables to find this out, but I want to do this in a cross-platform way.</p>
  
  <p>Is there any way I can do this with .NET (preferably using mscorlib)?</p>
  
  <p><strong>UPDATE</strong>: Okay, this is the code I ended up using:</p>
  
  <pre><code>string homePath = (Environment.OSVersion.Platform == PlatformID.Unix || 
                     Environment.OSVersion.Platform == PlatformID.MacOSX)
      ? Environment.GetEnvironmentVariable("HOME")
      : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
  </code></pre>