WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check If a File Is Locked


Question:

The only examples I have seen on how to check if a file is locked is to try to open it a catch the error. Is there no other way to identify if a file is locked w/o trapping an error?

Answer:

For file locking you would have to handle the error anyways. The file may not be locked when you check it but could then be locked when you try to go to open it. The checking would however remove many instances of the error. That said in this case your best best is to trap the error as there is no other good way of doing this, you could also call FileExist and check for the return value 2 to avoid having the error thrown but the error is really not that expensive. You should then wait a little bit before trying again if thats your overall goal.
Article ID:   W16987
File Created: 2007:07:03:14:27:30
Last Updated: 2007:07:03:14:27:30