Efficient way to check for changes to the contents of folders

Posted by MrVimes on Programmers See other posts from Programmers or by MrVimes
Published on 2012-11-30T16:10:13Z Indexed on 2012/11/30 17:19 UTC
Read the original article Hit count: 257

Filed under:

I am creating an application that maintains a database of files of a certain type in a given folder (and all subfolders) Initially the program will recurse the folders and add any file it finds of that type to the database.

I want the application to have the ability to re-scan the folder and add any files that were not there the last time the folders were scanned.

It can't use the date created property of the file because there is a high chance of a file being added to the folders that isn't a new file.

I am wondering what the most efficient way of doing this is, and if there is a way that doesn't involve checking each file is in the database already (which, if there are 5000 files would mean 5000 queries of a list 5000 items in size, or 25 million 'checks' for the sql engine to perform)

I suppose a more specific question to acheive the same goal would be - is there a property of a file (in Microsoft Windows) that will reliably tell you when that file arrived in that folder.

© Programmers or respective owner

Related posts about file-handling