vb.net 如何在应用程序启动时检查文件夹中的更改?

发布于 2024-09-03 12:40:26 字数 184 浏览 3 评论 0原文

当应用程序运行时,我使用 FileSystemWatcher 来监视文件夹。但是,如果应用程序未运行时文件夹发生更改怎么办?如何在应用程序启动时检查这些更改。

(例如,类似于 Windows Media Player 监视您的音乐文件夹的方式。即使您在未运行时将歌曲添加到该文件夹​​,它也会在下次运行时发现它们)

谢谢

while the application is running i'm using FileSystemWatcher to monitor the folder. But what if there are changes to the folder when the application is not running, how can I check for these changes when the application starts.

(similar to how windows media player, for example, monitors your music folder. Even when you add songs to that folder when it is not running, it does discover them when it runs next time)

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅浅 2024-09-10 12:40:26

您可以存储已在文件中找到的内容的列表,然后将其与启动时的当前状态进行比较。
否则,您可以创建一个在系统启动时启动的服务,并始终监视该文件夹,当您的应用程序启动时,它会轮询该服务以了解自上次轮询以来的任何更改。

You could store a list of what has already been found in a file and then compare it with the current state at startup.
Otherwise you could create a service that starts at system startup and always watches the folder and when your app starts up it polls the service for any changes since it last polled.

擦肩而过的背影 2024-09-10 12:40:26

您可以使用 System.IO.Directory 或 System.IO.DirectoryInfo 中的 LastWriteTime。

You can use the LastWriteTime which is in the System.IO.Directory or in the System.IO.DirectoryInfo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文