简体   繁体   English

什么时候在目录内触发FileSystemWatcher.Created事件?

[英]When does a FileSystemWatcher.Created event fire within a directory?

I am currently designing a Windows Service that will watch a folder for a file which is copied from another folder automatically. 我目前正在设计Windows服务,它将监视一个文件夹中是否存在从另一个文件夹自动复制的文件。 Will an event fire as soon as it sees this copy happening or after when the copy has completed? 看到此副本发生时或复制完成后,事件将立即触发吗?

Or is best to poll the folder every minute lets say? 还是最好每分钟轮询一次文件夹?

Will an event fire as soon as it sees this copy happening 看到此副本正在发生时,事件会立即触发吗

Yes. 是。

Or is best to poll the folder every minute lets say? 还是最好每分钟轮询一次文件夹?

That too, as a FileSystemWatcher can miss certain events, especially under stress (for example when a lot of files are being created in rapid succession). 那也是如此,因为FileSystemWatcher可能会错过某些事件,尤其是在压力下(例如,当快速连续创建大量文件时)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM