Sign in to follow this  

[.net] FileSystemWatcher--File moved?

Recommended Posts

It seems that finding out if a file has moved using the FileSystemWatcher class is a total pain. In my experiments, a file move tends to raise the following events: 1. Created (for new file) 2. Changed (for new file, possibly multiple times) 3. Changed (for new folder) 4. Deleted (for old file) 5. Changed (for old folder) I'm writing a class that simply spits out a FileMoved event when this happens, and it's been a royal pain to get it to work reliably. I've tried storing a cached version of all the file info in the directory tree I'm watching, then on every Deleted I check if the file info for the last file that was created and the cached file info for the file that was just deleted match up in terms of filename, modified timestamp, and size. It's a very bad hack and doesn't work very well. Has anyone here done this or have a good link? ~BenDilts( void );

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this