mvermand
mvermand

Reputation: 6117

c# filesystemwatcher move detection

I want to replicate all changes to a given folder. I use the FileSystemWatcher in C# and I can detect most changes. One type of change that I cannot detect easily is a move of a complete folder to the watched folder. I receive only a create-event for the folder but no events for the content of that moved folder. I can think of some logic to figure out if it is a move or just a creation of a new folder, but it seems awkward that it is quite hard to do this. Any suggestions in easy/out-of-the-box folder-move detection?

Thans a lot!

Upvotes: 1

Views: 778

Answers (1)

MobileX
MobileX

Reputation: 419

I receive only a create-event for the folder but no events for the content of that moved folder.

That's correct as OS does not "copy+delete" the folder internals. It's just "relink" the folder in the file system. As just a 'fast' idea - you cold check if 'created' folder is empty or not at the moment the create event received. If the folder is not empty you cold assume it was moved.

Upvotes: 1

Related Questions