File monitoring for all drive

Tim Golden mail at timgolden.me.uk
Fri May 25 01:06:52 EDT 2007


rohit wrote:
> hi
> i want to detect all file change operations(rename,delete,create....)
> on ALL THE DRIVES of the hard disk
> using the method ReadDirectoryChanges API , i.e program no. 3 in the
> webpage http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html
> .
> Please suggest some modification to the program so that i can detect
> changes to ALL the drives
> (to detect changes on c:\           set
> path_to_watch = "." to "c:\\"   but this works for only one drive

Well, to answer the question specifically: since the
Windows filesstem has no concept of a "root" above
the drive letters, the simplest thing to do is to
kick off a thread or a subprocess or what-have-you
for each drive letter.

The *shell* has the concept of a "My Computer" which
notionally sits above the various drives, but since
it isn't itself a drive and since I assume you're
only interested in local drives anyway and not the
rest of the shell-y stuff which sits underneath it,
you'd end up querying for local drives and going
the same path in any case.

TJG



More information about the Python-list mailing list