How to catch the details of the file copy/move event, such as the source file name How to catch the details of the file copy/move event, such as the source file name windows windows

How to catch the details of the file copy/move event, such as the source file name


This is because there is no such operation as "copy a file", as far as the filesystem is concerned.

When you run a file copying command, it actually opens the old file, creates the new file, reads content into memory, writes to the new files, then closes both. All the filesystem sees are writes; there's no taint-tracking system for determining that the data actually came from another file without modification.

The final step, that differentiates the file copy from writing data to a file normally, is that the metadata of the destination are changed to match the source. But again, the filesystem doesn't know why you're changing the attributes or which file you're matching them two.

The filesystem only has special awareness of linking and unlinking. So moving, which consists of "create second link to content; remove first link" is detectable. If copying were implemented as "create new link marked for copy-on-write" then you could discover it, but copy-on-write is not a very popular filesystem feature.


the thing is: you wont have a copy event fired for the folder "f1".

what does trigger the file watch for folder 1 is: updating a file, copy a file from other directory to "f1" or deleting a file.

you can try using two files in "f1"..at the same time you copy the file to "f2" you can update the second file, thus triggering the updating event handler..........

hope this helps....