Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 ?
Posted
Comments
Sergey Alexandrovich Kryukov 12-Nov-13 0:22am    
You language? application type? Why WMI?
—SA
Chakri Reddy 12-Nov-13 0:30am    
SQL-Server 2008,I need to check for new files in the shared location and need to capture the details(columns) in that file to my SQL-Server table for every 2min or 3 min, like this i need to check for new files in the shared location continuously for every 2 to 3 min so,iam using WMI. if we have any other approach can you suggest me that.
Sergey Alexandrovich Kryukov 12-Nov-13 0:38am    
What about your programming language?
—SA
Chakri Reddy 12-Nov-13 1:00am    
As of now we are trying to do that witout using any Programming Language through SSIS by using WMI Event task,is it possible or not?with WMI Event,if not can you suggest us how can we do that by using C#

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);
 
Share this answer
 
Comments
Chakri Reddy 12-Nov-13 8:00am    
The above File system watcher code watches the file in the specified folder is it right...?
What is "Refresh.txt" in the above code ?
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
 
Share this answer
 
it is the file or folder you want to check on
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900