MediaPortal Wiki > MediaPortal 2 > Contribute > Development > Modules > Core Services > FileEventNotifier


Redirected from 2 MEDIAPORTAL 2/Contribute/Development/4 Modules/Core Services/FileEventNotifier


    IFileEventNotifier is a service created to give an interface to the System.IO.FileSystemWatcher.

    The default implementation is FileEventNotifier.

    Interface Members

    IFileEventNotifier contains only 2 methods:

    • Subscribe(FileWatchInfo)
    • Unsubscribe(FileWatchInfo)

    The FileWatchInfo to unsubscribe must be the same object as the one used to subscribe. If it's not, an InvalidFileWatchInfoException will be thrown.


    FileWatchInfo contains all data regarding a watched file, the class is needed to subscribe and unsubscribe a watch.

    It's most important properties are the path, the filter, the changes to report, and the eventhandler to call.


    When initializing a new instance of FileWatchInfo:

    • A path leading to a directory must always end with '\'
    • A path leading to a file must never end with '\'

    This is especially necessairy if the path-to-watch is not available on the sytem at the time of FileWatchInfo's initialization, because then FileWatchInfo is not able to know if the path is a file or directory. This could lead to unexpected results.



    Watch files/directories

    FileEventNotifier is just like FileSystemWatcher able to watch changes on files and/or directories.

    Subscribe to unavailable paths

    FileEventNotifier supports subsriptions for unavailable paths. The path will be watched as soon as it comes available.

    Autorestore on path lost/retrieved

    Useful feature for watching files/directories on network shares, removable disks, ramdisks, ...

    When such a path is lost, the FileEventNotifier will autorestore the watch as soon as the path is available again.

    Events on path lost/retrieved

    FileEventNotifier will raise an event if a path is lost or retrieved.

    One event per change

    Only one event per change is sent.

    Example: when a new file is created, a single Created-event will be sent in stead of a the 3 events Created, Renamed, and Changed (which is how some applications create files).

    Advanced filtering

    FileEventNotifier supports multiple filters. Filters are case sensitive and can contain wildcards.

    The following table comes straight from MSDN, and demonstrates the use of wildcards:

    Filter string

    Watches the following files


    All files (default). An empty string ("") also watches all files.


    All files with a "txt" extension.


    All files ending in "recipe" with a "doc" extension.


    All files beginning with "win" with an "xml" extension.


    Matches the following: Sales July 2001.xlsSales Aug 2002.xlsSales March 2004.xls but does not match: Sales Nov 1999.xls


    Watches only MyReport.doc

    No events when filesize is increasing

    No events are raised when the filesize is still increasing.

    This is especially useful when the user creates a new large file in the watched path. The Created event will only be raised when the file is complete, this makes it save to immediately read tags or parse content from the file.

    The feature only works for files.

    Internal error handling

    All errorhandling is kept internal.


    NTFS Only

    The FAT file system is not supported.

    The FileEventNotifier will throw a NotSupportedDriveTypeException if such a path is subscribed,

    unless the path is specified by UNC (meaning the path is not watched, and without the subscriber knowing).

    Tag page (Edit tags)
    • No tags

    Running the latest version?

    V1.15.0 - released June 2016
    Releasenews | Download
    | Requirements

    MediaPortal RSS Feeds

    windows media centerNews & Blogs
    htpcP&S: New


    Contact | Press