unit Unit1;
interface
uses
//...
DirectoryWatch;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
Watch: TDirectoryWatch;
procedure OnNotify(
const Sender: TObject;
const Action: TWatchAction;
const FileName:
string);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OnNotify(
const Sender: TObject;
const Action: TWatchAction;
const FileName:
string);
begin
ShowMessage('
Action: ' + TRttiEnumerationType.GetName(Action) + sLineBreak + sLineBreak + '
FileName:' + sLineBreak + FileName);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Path:
string;
begin
Path := ExtractFilePath(Application.ExeName) + '
~TestVerzeichnis';
if ForceDirectories(Path)
then
begin
Watch := TDirectoryWatch.Create;
Watch.WatchOptions := [woFileName, woDirName, woAttributes, woSize, woLastWrite, woLastAccess, woCreation, woSecurity];
// hier am besten selber herausfinden was du brauchst
Watch.WatchActions := [waAdded, waRemoved, waModified, waRenamedOld, waRenamedNew];
// hier genau so
Watch.Directory := Path;
Watch.OnNotify := OnNotify;
Watch.Start;
end
else
MessageDlg('
Verzeichnis konnte nicht erstellt werden', TMsgDlgType.mtError, [mbOK], 0);
end;
end.