Delphi: Check whether file is in use -


I want to write / delete a file, but sometimes I get an accident if the file uses another program How do I check to see if the file has been opened with another process or can I open it for writing?

The problem is, when you want to see if you can get exclusive access and You can open the file, there may be some other access to the file, and you get the exception in any way.

The only fool

If not, you catch the exception, and the certified way to see if you can get a unique lock on the file, on the file Try and get a unique lock.

  • Do something else
  • Wait a little while and try again

It is one of the conditions of life where to ask better Sorry with permission :)


Comments