[Tutor] Watch folder code - follow up question
dfinner@Kollsman.com
dfinner@Kollsman.com
Wed, 9 Oct 2002 11:12:35 -0400
Thanks to Lei, I've tried building the first bit of the skeleton to watch a
folder.
import win32api
pathName = 'c:\\IDFIles'
bSubDirs = False
filter = FILE_NOTIFY_CHANGE_FILE_NAME
chgHandle = win32api.FindFirstChangeNotification(pathName, bSubDirs , filter )
print chgHandle
Generates the following:
Traceback (most recent call last):
File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 301, in RunScript
exec codeObject in __main__.__dict__
File "C:\Python22\Lib\DFScripts\DirWatcher.py", line 4, in ?
filter = 0 #FILE_NOTIFY_CHANGE_FILE_NAME
NameError: name 'FILE_NOTIFY_CHANGE_FILE_NAME' is not defined
Per the help in Win32API, filter is an int variable. If I substitue an integer
(1 or 2 for instance), for filter, I get back a chgHandle value.
I've poked around the web at various Win API sites and have not found anything
that converts the filter into an integer. Any idea what
FILE_NOTIFY_CHANGE_FILE_NAME is as an integer???
TIA
Doug
BTW - I found this while looking around. I'll probably try to convert this into
some Python-esque code.
http://www.codeproject.com/file/directorychangewatcher.asp