I open a Microsoft Access file normally and I can see its locked by Micorsoft Office. I then attempt to check if its writeable with PHP:
echo '|--> '.is_writeable('C:\wamp\www\Database1.accdb');
But it returns a 1. Surley, it should return a 0 when open?
Just to test, I then attempt to write to it:
$fh = fopen('C:\wamp\www\Database1.accdb', 'w+');
fwrite($fh, 'hello');
It lets me do so! Is there anyway I can make sure if a file is not open by another program?
When you open a Microsoft document regardless weather its a word, power-point or access file the application will create a file within the same directory that is marked as hidden, this file is what tell’s the office application that the file is being used.
the file in question is NOT Locked by the operating system therefore the OS Cannot determine weather the file is opened by an MS Application.
What you have to do is check to see if the lock file exists, this then will allow you to determine weather the document is currently open by the associated application.
Something like: