Tuesday, May 29, 2012

How many ways are there to create a File Watcher? Well, here's three at least...

MECUM – .NET TECHNOLOGY BLOG - Daily Problems – How to Write a Filewatcher in Three Possible Ways


During my excessive web-sessions regarding .NET I often stumble over questions and articles regarding file monitoring applications. Either as stand-alone applications or in conjunction with Windows Services.

For years know this discussions goes on. With this post I want to show the three methods I have used over the last few years and also give a good usage-scenario for “File Watchers” on Windows.

  • System.IO.FileSystemWatcher – The “Standard” Way
  • Using WMI – Windows Messaging [Management] Instrumentation to Watch Directories
  • The Third and Last Method to Write a FileWatcher – The Windows 7 API-Codepack


I've known about the first two methods, but the third was new to me. Sure I've known about the Windows API Code Pack for years, just didn't know I could use it this way. I love our industry, there's something to learn every day|hour|minute...


Related Past Post XRef:
Windows API Code Pack v1.1 Released (Think “Bug fix, new Shell/Thumbnail/Preview features, VS2010, xUnit, string localization, signed assemblies and more” release)
More Windows Code Pack and Windows 7 developing delightfulness
Windows 7 Code Pack v1.0 Released – Managed code to help get at the yummy Windows 7 filling…
Bridging to Managed Windows 7 Development – Vista Bridge to Windows Code Pack
Vista Bridge v1.4 Released – Now with custom controls for Common File Dialogs, BreadCrumb control and Aero Glass
Vista Bridge (v1.3) available on MSDN Code Gallery
It’s the Bridge to… Vista – Getting and installing Vista Bridge Sample Library

1 comment:

@awsomedevisger said...

Hi Greg, the last method was also unknown to me, until 3-4 days ago. Thank you for publishing!