Can I track the creation of each file on a Windows disk?

I am writing a program in Python that stores information for each file in the system. When it is installed, it will move through each file, but then I want to update it whenever a new file is created or when the file is moved. For example, in the Dropbox service, whenever I copy a file to my Dropbox directory, it immediately notices and uploads it to its server.

Is there a way to do this in Python without polling? I am thinking of some kind of event listener that fires when a file is created.

+3
source share
1 answer

Try one of the following:

, . ( ):

import watcher
w = watcher.Watcher(dir, callback)
w.flags = watcher.FILE_NOTIFY_CHANGE_FILE_NAME
w.start()

watcher - , API MSDN:

http://msdn.microsoft.com/en-us/library/aa365465(v=vs.85).aspx

, watcher.FILE_NOTIFY_CHANGE_FILE_NAME , :

. , .

+2

All Articles