如何创建一个监听更改文件或新文件的文件夹

发布于 2024-07-10 04:52:06 字数 235 浏览 7 评论 0原文

我有一个要求,我创建许多 SWC 文件(SWC 文件类似于 zip 或 jar 文件)。 我希望,每当我创建一个新的 swc 文件并将其添加到“特定文件夹”中时,这些文件应该自动提取(类似于 Apache Tomcat webapps 文件夹中发生的情况)。 请帮助我如何在 Windows 中执行此操作。 [注意:我知道我可以编写一个 ant/rake/gradle 脚本来为我做到这一点,但只是为了在 Windows 中探索更多如何实现这一点]

I have a requirement where I create many swc files (swc files are similar to zip or jar files). I want that, whenever I create a new swc file and add it in a "particular folder" then these files should automatically get extracted (similar to what happens in Apache Tomcat webapps folder). Please help me how to do that in Windows.
[Note: I know I can write a ant/rake/gradle script which can do this for me, but just to explore more in Windows how to achieve this]

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

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

发布评论

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

评论(6

时间你老了 2024-07-17 04:52:06

如果您使用的是 .NET,请使用 FileSystemWatcher 类。 (此处)

Use the FileSystemWatcher class if you're using .NET. (here)

最冷一天 2024-07-17 04:52:06

如果您不使用 .NET,则可以使用 FindFirstChangeNotification 函数用于监听文件系统更改。

If you are not using .NET, then you can use the FindFirstChangeNotification function to listen for filesystem changes.

诗化ㄋ丶相逢 2024-07-17 04:52:06

如果您想以 Windows 脚本方式执行此操作,则可以使用 WMI 事件观察器。
http://technet.microsoft.com/en-us/library/ms141130。 ASPX

If you want to do it in a windows scripted fashion, you would use a WMI Event Watcher.
http://technet.microsoft.com/en-us/library/ms141130.aspx

桃酥萝莉 2024-07-17 04:52:06

您可以使用 .NET FileSystemWatcher 来完成此任务。 (来自 c#、vb.net 等)
使用 FileSystemWatcher,您可以观察文件的创建、删除和修改并对这些事件做出反应。

you could use the .NET FileSystemWatcher to do this task. (from withing c#, vb.net, etc..)
with FileSystemWatcher you can observer creation, deletion and modification of files and react to those events.

浪漫人生路 2024-07-17 04:52:06

FileSystemWatcher 是 .Net 中显而易见的选择。

恕我直言,它不是一个好的组件。 很多时候,它会引发文件更改的双重事件,而我无法使用 FileSystemWatcher 进行简洁的实现。

FileSystemWatcher is the obvious choice in .Net.

IMHO, its not a good component. Many a times it raises double events for change of files and I have not been able to do a neat implementation using FileSystemWatcher.

油饼 2024-07-17 04:52:06

不要使用 .NET(针对儿童)
使用Win32 api通知(8行代码)

Don't use .NET (for kids)
Use Win32 api notifications (8 lines of code)

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