O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monitoring File System Activity

Before getting into ways to create and manipulate files, let’s look at how we can monitor file system activity. Such activity includes the creation, removal, renaming, and modification of files by any party using the file system. Far too often, people resort to polling techniques to check for the presence of a file instead of using some kind of monitoring API to observe file creation. Polling the file system isn’t cheap and involves excessive I/O.

Luckily, .NET exposes low-level file system APIs that enable you to watch activity. The component class used for this purpose is called FileSystemWatcher. Because this class is defined as a component (as discussed briefly in the preceding chapter), we can use it from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required