Check if file is Accessible
-
Hi, I need to open a file that is also opened in another application. when i try to open and read the file it says the file is being used by other program. in this case is there a way to open a file? How can i check if the file is accessible or not? regards, rnv
-
Hi, I need to open a file that is also opened in another application. when i try to open and read the file it says the file is being used by other program. in this case is there a way to open a file? How can i check if the file is accessible or not? regards, rnv
If the file is locked by the other application, or opened with DenyShare, there's no way you can open the file until the other application closes it and releases it's locks. The only way to check to see if the file is accessible is to try and open it. Catch an Exceptions thrown in a Try/Catch block. If the open fails, wait a bit, then try again. Eventually, the other app should close the file and you'll be able to open it. You could also try to only open the file for SharedRead, meaning you're application will not write to the file but will allow other processes to share access to the file. If your other application is denying Shared Read, you're out of luck. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome