[Tutor] RE: Watch folder code - follow up question
Justin Ezequiel
j.ezequiel@spitech.com
Fri, 11 Oct 2002 10:40:51 +0800
Doug,
I guess I should have told you where I got the value
I have Visual Basic installed on my machine and it comes with the 'API Text Viewer'
Among others, It has a list of constants
a Google search on FILE_NOTIFY_CHANGE_FILE_NAME also turned up this link
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20242914.html
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