我正在尝试使用watchdog监视System32上的目录,但是如果将路径更改为可正常工作的桌面上的文件夹,则不会发生任何事件。 该文件夹具有所有人的所有安全权限。
from watchdog.observers import Observer
from watchdog.events import (
PatternMatchingEventHandler, FileModifiedEvent,
FileCreatedEvent)
observer = Observer()
class Handler(PatternMatchingEventHandler):
def on_created(self, event: FileCreatedEvent):
print('File Created: ', event.src_path)
def on_modified(self, event: FileModifiedEvent):
print('File Modified: %s [%s]' % (
event.src_path, event.event_type))
observer.schedule(event_handler=Handler('*'), path='C:/Windows/System32/Tpar')
observer.daemon = False
observer.start()
try:
observer.join()
except KeyboardInterrupt:
print('Stopped.')
observer.stop()
observer.join()