Search notes:

System.IO.FileSystemWatcher (class)

System.IO.FileSystemWatcher monitors directories for changes of files and directories and notifies listeners of such changes.
The class inherits from System.ComponentModel.Component.
Possible types of events that can listed for are enumerated in System.IO.NotifyFilters. These events need to be combined with the enum System.IO.WatcherChangeTypes.

Watching a directory in PowerShell

function watch-directory {
   param (
      [string] $dir
   )

   $fsw = new-object System.IO.FileSystemWatcher  $dir

   $fsw.NotifyFilter          = [System.IO.NotifyFilters]::LastWrite
   $fsw.IncludeSubdirectories = $false

   while($true) {

    #
    # Watch directory for one second only to give user a chance
    # to break out of loop with ctrl-c.
    #
      $timeout = 1000

      [System.IO.WaitForChangedResult] $r = $fsw.WaitForChanged([System.IO.WatcherChangeTypes]::Changed, $timeout)

      if (-not $r.TimedOut) {
       #
       #  WaitForChanged returned because something changed in the
       #  watched directory, not because the timeout period
       #  was reached.
       #
         write-host ($r.Name + ": " + $r.ChangeType)
      }
   }
}
Github repository .NET-API, path: /System/IO/FileSystemWatcher/watch-directory.ps1

See also

The WinAPI functions ReadDirectoryChangesW and ReadDirectoryChangesExW.
Oracle's file watcher object.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1759525671, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/IO/FileSystemWatcher/index(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78