LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to detect if a file is locked by another program

I am using DBcad, an activeX component to implement a map in my application. During operation, it creates a database file to store graphic elements in.

If the database some how gets left open (or if another application is using the database) DBCad complains with a dialog that there is "No database". It doesn't, however, return a labview error.

Since I can't change the behavior of the OCX control, I need to create a wrapper that detects that the database is not accessible. When I use the LABView 'delete' function or the 'file/database info' function when the file is in use, I get a 'File not Found' error.

How can I tell the difference between the file really not existing and the file not being accessible?

I am using Windows XP/2000, not UNIX/Linux so I can't just look at the permissions

EDIT: Never mind. I figured it out already. OOPS

Message Edited by terminalman90 on 05-06-2005 04:31 PM

0 Kudos
Message 1 of 3
(2,560 Views)
Whenever you figure out the answer please post it so that other readers will know the answer.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 2 of 3
(2,552 Views)


@jhoskins wrote:
...post [your answer] so that other readers will know the answer.




Okay.

My solution is to make a 'wrapper' VI that takes the name of the database file. Since I am going to create a new database with the same name and I don't care about the previous content, I can safely delete the file. If the 'delete' function returns a file permission error (8), I know that the file is locked and I can either create a new name for the database or return an error (like the OCX *should* have done).

My mistake was that I forgot to include the '.dbf' extension so I was getting a 'file not found' (well, DUH) instead of the 'file permission' error like I was expecting.
0 Kudos
Message 3 of 3
(2,547 Views)