Introduction

ATFileNotification Component

ATFileNotification is a Delphi/C++Builder non-visual component, which allows to watch for files/directories changes and to fire an event when change occurs.

It is improved version of fisFileNotification component, which was originally written by FIS House and is currently available on Torry.net. In 2006 year I could not contact FIS House about their original component, since their home site www.fishouse.com was down.

Improvements are:

  • Component made Unicode compatible
  • FileName property added: you can watch for changes in a single file
  • Attempt to make component thread-safe
  • Compat. with newer Delphi


Installation

To install the component in the Delphi/C++Builder IDE:
  • Create a new package
  • Add AT*.pas files to this package
  • Compile, then install this package

Component will be installed into the "Samples" page of component pallette.


Usage: Properties

Properties

Options
 Set of flags specifying what file-system properties to watch. They are self-descriptive:
  • foNotifyFilename: files names
  • foNotifyDirname: directories names
  • foNotifyAttributes: attributes
  • foNotifySize: files sizes
  • foNotifyLastWrite: last modification time
  • foNotifyLastAccess: last access time
  • foNotifyCreation: creation time
  • foNotifySecurity: NTFS security attributes
Notes:
  • foNotifyDirname and foNotifySecurity options apply only for a directory (when Directory property is set).
Directory Name of directory to watch.
See note for FileName.
FileName Name of file to watch.
Note:
  • You may set Directory or FileName, not both of them.
Subtree | Enables watching of subdirectories of specified directory. Applies only for a directory.
Enabled (public) | Alternative to Start/Stop methods to increase readability of your source. When set to True it calls Start, when set to False it calls Stop.


Usage: Methods

Methods

procedure Start;
Starts watching thread.
procedure Stop;
Stops watching thread.


Usage: Events

Events

OnChanged Fired when file or directory change occurs.


License

This package, unless otherwise stated in the particular source code file, is distributed under Mozilla Public License Version 1.1 (the "License"). You may obtain a copy of the License at http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

Copyright © 2006-2007 Alexey Torgashin.


Versions history

1.1.6 (sep 2012):
  • Fixed: issue with timing: if file is modified almost immediately after watching start, watch thread didn't see it. Fix by: Tommi Prami.
1.1.5 (jul 2010):
  • Fixed: should be compatible with D2010 now. Taken TTimer from D7.
  • Demo: removed Tnt usage, should work with D2009+.
1.1.4 (Nov 2007):
  • Added: ATFileNotificationSimple additional component.
1.1.3 (Mar 2007):
  • Changed: License updated to MPL 1.1.
  • Changed: Source formatting.
1.1.2 (Oct 2006):
  • Fixed: Possible deadlock on calling Stop (thanks to Miguel Gastelumendi, mgd (at) satelier.com.br).
  • Added: Enabled property.
1.1.1 (Sep 2006):
  • Added: Attempt to make component thread-safe (need feedback about it).
1.1.0 (Sep 2006):
  • Initial release, below are the changes since "fisFileNotification" version:
    • Added: Component made Unicode compatible, Directory property is now WideString.
    • Added: FileName property (also WideString): separate filename can be monitored. Note that not all notify options are applied for a filename, but most are.
    • Added: Security notify option.
    • Changed: Some properties were renamed.
    • Changed: Component appears on "Samples" page.


Contacts

If you encounter problems with this component, or you have comments or suggestions, contact the author:

Alexey Torgashin
http://www.uvviewsoft.com