How to detect a file if it is locked by another process
-
Hi all, I want to overwrite an existing file (acttually, it's an excel file). But i don't know whether it's in use or locked by another process or not. Is there a way to check that. Thanks.
use a file which is locked u will get an exception handle that exception using try catch block ... Exception handling tat's all
-
Hi all, I want to overwrite an existing file (acttually, it's an excel file). But i don't know whether it's in use or locked by another process or not. Is there a way to check that. Thanks.
If you're using the Excel PIAs then the
_Workbook
class has aReadOnly
property that's useful for determining if the file is a readonly file or if an instance of Excel already has the workbook open. Not sure if it can tell if it's locked by any other process, but it does know if it's locked by Excel.