views:

177

answers:

6

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]

+3  A: 

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

Paul
A: 

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.

Joachim Kerschbaumer
+1  A: 

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

EBGreen
A: 

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

.Net is for kids? You obviously need to wring your brain out: it's full of dirty water.
Jonathan C Dickinson
Btw, it is 0 lines of code in .Net if you use the Forms designer.
Jonathan C Dickinson
+2  A: 

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

Greg Hewgill
A: 

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.

nils_gate