Hello,
I am working on project that requires checking to see if a file is open or closed. The application takes the information in the file on one system and places it on another system to modify. I have tried setting up a file lock so that I can lock the file using the FileChannel and FileLock api's. I am in a windows environment. When I
test the program with the file already open in notepad, the program is still able to get a lock on the file even though I expect it not to be able to. The only time it fails is if I run another
java thread that attempts to get the lock for the same file. However, it does not seem to work if a another user has it "open" using some type of editor.
Is there anyway at all to check to see if the file is open or closed and gain exclusive access to that file? For example, a user is editing the file using Microsoft
Word, and my java application needs exclusive access to that file needs to check if it is open period. For the purposes of this project, there is highly sensitive information that needs to be transferred, and it can not be being edited by an outside application while the application is moving the file. Any guidance would be appreciated.