Page 1 of 1

Object in Use

Posted: Wed May 25, 2011 9:13 pm
by djrikki
Hi guys,

Is there a command or routine I can use to detect whether a file is already in use/being written to?

Re: Object in Use

Posted: Sat May 28, 2011 12:17 pm
by airsoftsoftwair
No. A dirty trick would be to make a backup of the file in Ram:, then try to delete it using DeleteFile(). Then check with GetLastError() if deleting succeeded... if it did, then the file is not in use and you have to restore it using the backup made earlier. If it couldn't be deleted, then it is in use. But that is really a dirty technique... not recommended.

Re: Object in Use

Posted: Thu Jun 02, 2011 7:34 pm
by Bugala
If you are checking only files that you are accessing with that same problem, you could also keep list of open file names and compare to be accessed file to them.