Disk monitoring with Warden

In today’s post I’m going to briefly describe one of the latest watchers designed especially for the disk & file monitoring.
If you’re looking for a new plugin to the Warden that will allow you to ensure e.g. that all of required files are available – you’ve found the right place.


As usual, let’s start with the example, yet this one will be a bit more sophisticated than usual:

In the example above, we want to check the following: 2 files, 2 partitions, 1 directory and also ensure that the disk has at least 95MB of a free space.

As you can see, the disk watcher has quite a few options available, such as:

  • WithPartitionsToCheck() – one or more partitions to check e.g. “C:\”
  • WithDirectoriesToCheck() – one or more directories to check e.g. “C:\Files”.
  • WithFilesToCheck() – one or more files to check e.g. “C:\Files\Log.txt”.

Surely, we can also configure this watcher by using the available extension methods:

The result object that you can use inside the EnsureThat() and EnsureThatAsync() methods is quite interesting though. Actually, it contains a lot of the informative data that will help you the validate the performed check, but I’m not going to paste that wall of code here (click on the link in the end if you would like to learn more about it).

To install the package, which is currently in the prerelease version, run the following command in the Package Manager:

If you would like to provide a custom configuration, the following interface is ready to be implemented:

The default DiskChecker uses the System.IO under the hood.

In order to find out more about the DiskCheck type and the watcher itself, please click here.

Leave A Comment

Your email address will not be published. Required fields are marked *