Hi all,

I have two identical programs polling for files in the same directory.

I wish to have one program (whichever gets there first) lock the file, carry out some processing with the data within and then delete the file.

My problem is that I do not seem to be able to delete the file whilst under lock, even when it is the present thread/program that holds the lock. I therefore have to close the lock and then try to delete. During this time my second program may lock the file and process, I do not want this to happen, I just want to delete the file (preferably whilst under lock).

Is there any way to do this?