For example, FileSystemWatcher catches some change in the monitored directory.

Is it possible to distinguish the removal of files from moving, as well as in the second case to find out where the files are moved?

  • one
  • No, but the question is a little different. After all, if someone from the outside will move files from one place to another, then they are supposed to be deleted. The question also arises, is it possible to understand where the files are being moved? - iluxa1810
  • So you try. By the way, there is no move event - Grundy
  • It depends on what is considered a displacement. And if the file is moved to another disk? And if the network? And if on the FTP server? And if the archive? - VladD
  • We consider all the cases described by you as moving. - iluxa1810

1 answer 1

If you need to track the removal and movement of files within the monitored directory, then you need a couple of OnDeleted / OnCreated events.

If you need to track file movements from the monitored directory, then, alas, FileSystemWatcher does not support this. For him, any file transfer is deletion. And you can not distinguish it from the actual removal.

Fast google prompts that file system watcher can be used (via WinAPI). There is also a commercial library CallbackFilter , which apparently does everything for you.