I have seen examples of determining ownership of a file. Is there a way to determine who is accessing a file?

I have a program that needs to overwrite files. If one of these files is currently in use, I want to be able to inform the administrator that the file is currently being accessed and who is accessing the file.

If there is a way to do this with an API, that would be cool.

Thanks.