10
4
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?
2
Should probably be asked on superuser. But still: movefile should be able to do the trick in any case. It's surprising that you cannot simply delete the hard link though, actually it should be a completely "unrelated" file.
– Damon – 2013-11-20T12:30:24.223