[python-win32] subtree problem with ReadDirectoryChangesW
Chris
zqc53 at 126.com
Sat Jan 13 20:29:30 CET 2007
Hi!
I got a problem with win32file.ReadDirectoryChangesW(),that is how to watch a root dir with subdirs?
Here is my code:
[START]
import win32api,win32file,time,threading
from win32con import *
class worker(threading.Thread):
pass
def watch_dir_1():
dirName = "d:\\"
hdir = win32file.CreateFile(
dirName,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
pywintypes.SECURITY_ATTRIBUTES(),
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
0
)
print hdir
while(1):
time.sleep(.5)
print win32file.ReadDirectoryChangesW(
hdir,
50,
100,
FILE_NOTIFY_CHANGE_LAST_WRITE,
None,
None
)
def watch_dir():
watch_worker = worker()
watch_worker.run = watch_dir_1
watch_worker.start()
watch_dir()
time.sleep(500)
[END]
The result is that the api works good only if the changes in in top-level and second-level, else I got a () only.
I search for msdn and found that there is a parameter 'BOOL bWatchSubtree' in the original api, where is it in pywin32?
What can I do now ? Maybe only I can do is to create a watcher thread for each directory in d:\\
Thanks for your help.
Chris
2007-12-14
More information about the Python-win32
mailing list