FileSystemWatcher的VS轮询来监视文件更改 [英] FileSystemWatcher vs polling to watch for file changes
问题描述
我需要设置的手表在一个目录中创建文件的应用程序,无论是本地或网络驱动器上。
I need to setup an application that watches for files being created in a directory, both locally or on a network drive.
请问 FileSystemWatcher的
或定时轮询将是最好的选择。我已经使用在过去这两种方法,但是没有广泛。
Would the FileSystemWatcher
or polling on a timer would be the best option. I have used both methods in the past, but not extensively.
哪些问题(性能,可靠性等)与有两种方法?
What issues (performance, reliability etc.) are there with either method?
推荐答案
我已经看到了文件系统观察生产和测试环境失败。现在我认为这是一种方便,但我不认为这是可靠的。我的格局已经观看与文件系统观察变化,但偶尔轮询赶上丢失的文件变化。
I have seen the file system watcher fail in production and test environments. I now consider it a convenience, but I do not consider it reliable. My pattern has been to watch for changes with the files system watcher, but poll occasionally to catch missing file changes.
编辑:如果你有一个UI,你也可以给你的用户刷新更改,而不是投票的能力。我会用一个文件系统观察结合起来这一点。
If you have a UI, you can also give your user the ability to "refresh" for changes instead of polling. I would combine this with a file system watcher.
这篇关于FileSystemWatcher的VS轮询来监视文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!