I have a stream that I use ReadDirectoryChangesWfor notification when a file is added or deleted in a folder.
For each new image, I open the file and create a thumbnail of the image. It would seem, however, that I receive a notification before the file is completely copied to the destination folder, in which case I receive only a partial sketch. (Files are copied from remote locations to a central server, and the network may slow down during peak times.)
I check if the file is being used, but this does not work with image files.
HFileRes := CreateFile(pchar(Filename), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) ;
Result := (HFileRes = INVALID_HANDLE_VALUE);
if (not Result) then
CloseHandle(HFileRes) ;
My question is this: is there a way to detect when the file is fully copied, or am I just waiting for the file size or the time of the last modification to change from the moment of the last check?
Regards, Peter
source
share