What is the impact of a FileSystemWatcher on a hard drive?

前端 未结 2 1682
深忆病人
深忆病人 2020-12-21 12:14

I\'ve used FileSystemWatcher in the past. However, I am hoping someone can explain how it actually is working behind the scenes.

I plan to utilize it in an applicat

相关标签:
2条回答
  • 2020-12-21 13:13

    The short answer is no. The FileSystemWatcher calls the ReadDirectoryChangesW API passing it an asynchronous flag. Basically, Windows will store data in an allocated buffer when changes to a directory occur. This function returns the data in that buffer and the FileSystemWatcher converts it into nice notifications for you.

    0 讨论(0)
  • 2020-12-21 13:15

    Nothing like that. The file system driver simply monitors the normal file operations requested by other programs that run on the machine against the filters you've selected. If there's a match then it adds an entry to an internal buffer that records the operation and the filename. Which completes the driver request and gets an event to run in your program. You'll get the details of the operation passed to you from that buffer.

    So nothing actually happens the operations themselves, there is no extra disk activity at all. It is all just software that runs. The overhead is minimal, nothing slows down noticeably.

    0 讨论(0)
提交回复
热议问题