I am getting significantly unreliable results using ReadDirectoryChangesW, attempting to use a simplified version of the codes that had been presented to me in my last query for help..
It's kind of messy, but here's the relevant bits of code.. if os.name == 'nt': self.filehandlelist[site] = {} self.filehandlelist[site]['dir'] = dir self.filehandlelist[site]['handle'] = win32file.CreateFile(dir, 0x0001, win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, win32con.FILE_FLAG_BACKUP_SEMANTICS | win32con.FILE_FLAG_OVERLAPPED, None) self.filehandlelist[site]['overlap'] = pywintypes.OVERLAPPED() self.filehandlelist[site]['overlap'].hEvent = win32event.CreateEvent(None, 0, 0, None) self.filehandlelist[site]['buffer'] = win32file.AllocateReadBuffer(1024) print "Add to filehandlelist: ", self.filehandlelist[site] .... if os.name == 'nt': for handle in self.filehandlelist: # print "check folder ", self.filehandlelist[handle] results = win32file.ReadDirectoryChangesW(self.filehandlelist[handle]['handle'], self.filehandlelist[handle]['buffer'], True, win32con.FILE_NOTIFY_CHANGE_FILE_NAME | win32con.FILE_NOTIFY_CHANGE_DIR_NAME | win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES | win32con.FILE_NOTIFY_CHANGE_SIZE | win32con.FILE_NOTIFY_CHANGE_LAST_WRITE | win32con.FILE_NOTIFY_CHANGE_SECURITY, self.filehandlelist[handle]['overlap']) if win32event.WaitForSingleObject(self.filehandlelist[handle]['overlap'].hEvent, 100) == win32event.WAIT_OBJECT_0: numbytes = win32file.GetOverlappedResult(self.filehandlelist[handle]['handle'], self.filehandlelist[handle]['overlap'], False) win32event.ResetEvent(self.filehandlelist[handle]['overlap'].hEvent) if numbytes == 0: continue for action, file in win32file.FILE_NOTIFY_INFORMATION(self.filehandlelist[handle]['buffer'], numbytes): full_filename = os.path.join(self.filehandlelist[handle]['dir'], file) print "file ", full_filename, "updated action ", action if full_filename not in self.filelist: self.addImportFile(full_filename, site) if action == 1 or action == 3: # created or updated self.import_file_dict(full_filename, self.filelist[full_filename][0], self.filelist[full_filename][1]) elif action == 2: # file deleted del self.filelist[full_filename] ... it feels like i'm doing something wrong here, but for the life of me, i can't seem to pinpoint it. -- Cheers, - Eric _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32