20.12. Watching Files Programmatically

Now that you have a better handle on the use of various readers and writers, you'll look at the role of the FileSystemWatcher class. This type can be quite helpful when you wish to monitor (or "watch") files on your system programmatically. Specifically, you can instruct the FileSystemWatcher type to monitor files for any of the actions specified by the System.IO.NotifyFilters enumeration (many of these members are self-explanatory, but you should still check the .NET Framework 4.0 SDK documentation for more details):

public enum NotifyFilters
{
  Attributes, CreationTime,
  DirectoryName, FileName,
  LastAccess, LastWrite,
  Security, Size
}

To begin working with the FileSystemWatcher type, you need to set the ...

Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.