title: SHGetKnownFolderPath / Environment.GetFolderPath() returning wrong value for public documents
body: <p>I got a somewhat strange error when trying to resolve the <code>CommonDocuments</code> directory. 
  It keeps resolving to the wrong directory, after the CommonDocuments directory has been <strong>redirected / moved</strong> to a new location using Windows Explorer (Properties->Path from the context menu).</p>
  
  <p>a minimal working piece of code would be:</p>
  
  <pre><code>namespace CommonDocumentsTest
  {
      class Program
      {
          private static readonly Guid CommonDocumentsGuid = new Guid("ED4824AF-DCE4-45A8-81E2-FC7965083634");
  
          [Flags]
          public enum KnownFolderFlag : uint
          {
              None = 0x0,
              CREATE = 0x8000,
              DONT_VERFIY = 0x4000,
              DONT_UNEXPAND= 0x2000,
              NO_ALIAS = 0x1000,
              INIT = 0x800,
              DEFAULT_PATH = 0x400,
              NOT_PARENT_RELATIVE = 0x200,
              SIMPLE_IDLIST = 0x100,
              ALIAS_ONLY = 0x80000000
          }
  
          [DllImport("shell32.dll")]
          static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
  
          static void Main(string[] args)
          {
              KnownFolderFlag[] flags = new KnownFolderFlag[] {
                  KnownFolderFlag.None,
                  KnownFolderFlag.ALIAS_ONLY | KnownFolderFlag.DONT_VERFIY,
                  KnownFolderFlag.DEFAULT_PATH | KnownFolderFlag.NOT_PARENT_RELATIVE,
              };
  
  
              foreach (var flag in flags)
              {
                  Console.WriteLine(string.Format("{0}; P/Invoke==&gt;{1}", flag, pinvokePath(flag)));
              }
              Console.ReadLine();
          }
  
          private static string pinvokePath(KnownFolderFlag flags)
          {
              IntPtr pPath;
              SHGetKnownFolderPath(CommonDocumentsGuid, (uint)flags, IntPtr.Zero, out pPath); // public documents
  
              string path = System.Runtime.InteropServices.Marshal.PtrToStringUni(pPath);
              System.Runtime.InteropServices.Marshal.FreeCoTaskMem(pPath);
              return path;
          }
      }
  }
  </code></pre>
  
  <p><strong>Expected behaviour:</strong><br>
  Output is <code>D:\TestDocuments</code></p>
  
  <p><strong>Actual behaviour:</strong><br>
  Output is <code>C:\Users\Public\Documents</code></p>
  
  <blockquote>
    <p>None; P/Invoke==>C:\Users\Public\Documents<br>
    DONT_VERFIY, ALIAS_ONLY; P/Invoke==><br>
    NOT_PARENT_RELATIVE, DEFAULT_PATH; P/Invoke==>C:\Users\Public\Documents</p>
  </blockquote>
  
  <p>The correct value is stored in the Windows Registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Documents), but it is not returned by <code>SHGetKnownFolderPath</code> (or <code>Environment.GetFolderPath</code>)</p>
  
  <p>OS: Windows 7 Professional x64<br>
  .NET Framework v4.0.30319 
  Application is compiled for <strong>x86 CPU</strong></p>
  
  <p>What I tried so far:</p>
  
  <ul>
  <li>restarting my application</li>
  <li>restarting the computer</li>
  <li>calling <code>Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);</code></li>
  <li>direct calls to Win32-API SHGetKnownFolderPath</li>
  </ul>
  
  <hr>
  
  <p><strong>EDIT 2</strong>
  Steps to reproduce: </p>
  
  <ol>
  <li>deactivate UAC on your computer [and restart!] </li>
  <li>go to C:\Users\Public\ </li>
  <li>right click on "Public Documents" folder and select
  <code>Properties</code> </li>
  <li>select the 'Path' tab </li>
  <li>click 'Move...' and select a (new) folder on drive <code>D:</code> called <code>TestDocuments</code> </li>
  <li>click 'Apply'</li>
  <li>accept to move all files to the new location start the minimal
  application above</li>
  </ol>