通过WMI事件监视器任务监视共享文件夹 [英] Watching shared folder through WMI Event Watcher Task

查看:117
本文介绍了通过WMI事件监视器任务监视共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从WMI事件观察器任务中观看共享文件夹。在共享文件夹(例如:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\我尝试了一个本地文件夹,它运行没有任何问题。但是,当我尝试共享文件夹时,它不起作用。它不会抛出任何消息。但它不会触发事件,即使是在共享文件夹中创建的新文件。



我将WMI连接配置为服务器名称的\\localhost Windows身份验证和\root\cimv2到命名空间字段。



请指导我如何从WMI事件监视器任务监视共享文件夹?是否可以使用WMI事件或不?

I need to watch a shared a folder from WMI Event Watcher Task. When ever a new file created in a shared folder (Ex : \\Server\Folder), WMI Event Watcher Task should fire the event. I tried a local folder and it's running without any issue. However, when I tried a shared folder, it didn't work. It doesn't throw any message. But it doesn't fire the event, even a new file created in the shared folder.

I configured WMI connection as \\localhost to the server name with windows authentication and \root\cimv2 to namespace field.

Please guide me how to monitor a shared folder from WMI Event Watcher Task?Is it possible with WMI Event or not ?

推荐答案

使用以下代码

use the below code
FileSystemWatcher watcher = new FileSystemWatcher()
                {
                    Path = FilePath,
                    Filter = "Refresh.txt"
                };
                watcher.EnableRaisingEvents = true;
                watcher.Created += new FileSystemEventHandler(watcher_Created);
                watcher.Changed += new FileSystemEventHandler(watcher_Changed);


WMI执行轮询,这总是很糟糕。你可以考虑另一种选择:使用 System.IO.FileSystemWatcher

http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110% 29.aspx [ ^ ]。



-SA
WMI performs polling, which is always bad. You can consider the alternative: using System.IO.FileSystemWatcher:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx[^].

—SA


它是您要检查的文件或文件夹
it is the file or folder you want to check on


这篇关于通过WMI事件监视器任务监视共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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