On a Windows NTFS file system, I have a file (say,
orig.mp3). I open this file, through this path
orig.mp3, in such a way that it is in use (say, by playing it in VLC).
Then I create a hard link (
cmd /c mklink /h link.mp3 orig.mp3). This results in two NTFS paths pointing to exactly the same file.
Finally I try to delete linked file again (
del link.mp3, or delete in Windows Explorer).
This fails with an error: "The process cannot access the file because it is being used by another process."
Why? And more importantly: how can I avoid this (apart from making sure no process has the original file in use)? Can I perhaps tell Windows to do a 'delayed delete', so that the linked file is automatically deleted when the original is no longer in use?