title: In .NET, how do I Create a Junction in NTFS, as opposed to a Symlink?
body: <p>I'm trying to create an NTFS Junction.  From the cmd line I can do this using the <a href="http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx" rel="noreferrer">junction.exe tool from sysinternals</a>.  The output of a DIR cmd for a junction looks like this: </p>
  
  <pre><code> Volume in drive C has no label.
   Volume Serial Number is C8BC-2EBD
  
   Directory of c:\users\cheeso\Documents
  
  03/22/2009  09:45 PM    &lt;JUNCTION&gt;     My Music [\??\c:\users\cheeso\Music]
  05/11/2007  05:42 PM    &lt;DIR&gt;          My Received Files
  03/22/2009  09:46 PM    &lt;JUNCTION&gt;     my videos [\??\c:\users\cheeso\Videos]
  </code></pre>
  
  <p>I read somewhere that Junctions are a subset of Symbolic Links.  </p>
  
  <p>So I tried using <a href="http://msdn.microsoft.com/en-us/library/aa363866(VS.85).aspx" rel="noreferrer">CreateSymbolicLink</a> to create a Junction.  When I do this, I actually get a Symlink, not a junction.</p>
  
  <pre><code>09/09/2009  11:50 AM    &lt;SYMLINKD&gt;     newLink [.\]
  </code></pre>
  
  <p>There is also <a href="http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx" rel="noreferrer">CreateHardLink</a>.  The doc there says junctions (aka "Reparse Points") are a subset of hardlinks. but I can't seem to get this call to work. It completes but there is no hardlink or junction created. </p>
  
  <p>I'm using .NET/C# and the imports look like this: </p>
  
  <pre><code>    [Interop.DllImport("kernel32.dll", EntryPoint="CreateSymbolicLinkW", CharSet=Interop.CharSet.Unicode)]
      public static extern int CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
  
      [Interop.DllImport("kernel32.dll", EntryPoint="CreateHardLinkW", CharSet=Interop.CharSet.Unicode)]
      public static extern bool CreateHardLink(string lpFileName,
                                               string lpExistingFileName,
                                               IntPtr mustBeNull);
  </code></pre>
  
  <p>What am I doing wrong?<br>
  How can I create a Junction from within C#?</p>