Directory Watch
Directory watch class, that can monitor the selected directory included with sub-directories. Main features:
- Simple to use class, that enables you to watch for all changes in a given directory
- Watch only the selected directory or also all its sub-directories
- You can define exactly what notifications you will receive
DirectoryWatch download: Version 1.0.1 (24.01.2010)
The demo bellow shows the basic usage of DirectoryWatch. If you have trouble using the code or have any other questions, please contact me directly using the “Contact” page.
Sample usage:
procedure TfMain.btnStartClick(Sender: TObject); begin FDirectoryWatch.WatchSubTree := cbWatchSubdirectories.Checked; FDirectoryWatch.Directory := eDirectoryName.Text; FDirectoryWatch.Start; btnStart.Enabled := False; btnStop.Enabled := True; end;
procedure TfMain.OnNotify(const Sender: TObject; const Action: TWatchAction; const FileName: string); var ListItem: TListItem; begin lvWatchActions.Items.BeginUpdate; try ListItem := lvWatchActions.Items.Add; ListItem.Caption := GetEnumName(TypeInfo(TWatchAction), Integer(Action)) ; ListItem.SubItems.Add(FileName); finally lvWatchActions.Items.EndUpdate; end; end;