可以使用filesystemwatcher双向检测变更和检测无变化。 [英] Can filesystemwatcher be used both ways, for detecting change and detecting no change.
问题描述
你好,女士们,先生们。
我的问题听起来很简单,我有一个我想要监控的文件夹。在 无变化 之前,程序不关心该文件夹。我最初的想法是使用 FileSystemWatcher 作为带有if语句的扫描程序(发现可能不可能)。
注意:我这样做是作为控制台应用程序。
任何人都可以指出我正确的方向,如果这似乎是一个死胡同。
请。
我有什么试过:
https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher.changed?view= netframework-4.7.2
唯一可以判断没有发生任何事情的方法是检查自上次发生以来的时间:这样你就可以说在最后'n'分钟没有发生任何事件。当'n'超过阈值时,你可以假设你的文件夹没有变化。
这个门槛应该是多少......好吧,这取决于你!
Hello, ladies and gentlemen.
My problem sounds quite simple, I have a folder that I want to monitor. The program doesn't care about that folder until there is no change in it. My initial thought was to use FileSystemWatcher as a scanner with an if statement (found out that may not be possible).
Note: I'm doing this as a console application.
Can anyone point me in the right direction, if this seems like a dead end.
Please.
What I have tried:
https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher.changed?view=netframework-4.7.2
The only way to tell that nothing has happened is to check the time since the last time it did: that way you can say that "no event has happened in the last 'n' minutes". When 'n' exceeds a threshold, you can assume there has been no change in your folder.
What that threshold should be ... well, that's up to you!
这篇关于可以使用filesystemwatcher双向检测变更和检测无变化。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!