 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Nov 20, 2006 4:44 pm Post subject: Cannot delete directory after calling FindCloseChangeNotific |
|
|
I've written a small FileMonitor thread which monitors for file changes
in a certain directory.
I've used standard FindFirstChangeNotification and
FindCloseChangeNotification. The problem is that after the thread
executes, I can't delete the monitored directory until I close the
whole application. A call to FindCloseChangeNotification returns True,
which means that Windows successfully closed the monitor handle, but
still when I try to delete that (empty) folder I get an I/O 32. The
code for the thread is very small, so I'll post it here as a whole:
-----------------------------------------------------------
constructor Create(Suspended: Boolean=False); override;
begin
inherited;
FreeOnTerminate=True;
end;
procedure TFileMonitor.Execute;
var
H: Cardinal;
begin
H := FindFirstChangeNotification(PChar(FPath), False,
FILE_NOTIFY_CHANGE_LAST_WRITE or FILE_NOTIFY_CHANGE_FILE_NAME);
if H = INVALID_HANDLE_VALUE then
Terminate
else
try
while not Terminated do
begin
WaitForSingleObject(H, INFINITE);
if not FileExists(FFileInfo.LocalFilePath) then
begin
Terminate;
break;
end;
Synchronize(...);
if not FindNextChangeNotification(H) then
begin
Terminate;
break;
end;
end;
finally
FindCloseChangeNotification(H)
end;
end;
-----------------------------------------------------------
Has anyone had a similar problem? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|