Detect directory changes

I need to track the folder and its subdirectories for any file manipulations (add / remove / rename). I read about FileSystemWatcher, but I would like to track changes between each program launch or when the user clicks the Check for Changes button (FSW seems more focused on detecting runtimes). My first thought was to iterate over all the (sub) directories and the hash of each file. Then combine all the hashes (which were ordered) and the hash. When I want to check for changes, I repeat the process and check if the hashes match.

Is this an effective way to do this? Also, as soon as I detected a change, how do I know which file was added, deleted, or renamed as quickly as possible?

As a side note, I am not opposed to using scripts to do this if they are faster, as long as these scripts do not require end users to install anything, and scripts can notify my C # application of the changes.

+1
source share
2 answers

We cope with this by storing all the files found in the database along with their latest modification time.

Each time we go through the files, we check the database for each file: if it does not exist in the database, it is new, and if it exists, but the timestamp is different, it has changed.

, ToBeDeleteed , . , , , ToBeDeleted.

+2

, "" . , , . , :

  • , "" "" .
  • , ,
  • , , , (, , , 100% , )
+2

All Articles