可以使用filesystemwatcher双向检测变更和检测无变化。 [英] Can filesystemwatcher be used both ways, for detecting change and detecting no change.

查看:58
本文介绍了可以使用filesystemwatcher双向检测变更和检测无变化。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,女士们,先生们。

我的问题听起来很简单,我有一个我想要监控的文件夹。在 无变化 之前,程序不关心该文件夹。我最初的想法是使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆