Riddle me thisHard links & file moves

time to read 1 min | 200 words

What would you expect the following code to output?

File.WriteAllText("a","1");
DirectoryBackup.CreateHardLink("b", "a", IntPtr.Zero);
File.WriteAllText("a","2");
if(File.Exists("c"))
    File.Delete("c");
File.Move("b","c");
File.WriteAllText("a", "3");
Console.WriteLine(File.ReadAllText("c")); 

CreateHardLink is:

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);

More posts in "Riddle me this" series:

  1. (12 Oct 2010) File access & Multi threading
  2. (06 May 2010) String outputs
  3. (02 May 2010) Hard links & file moves