Windows file locks on Paradox files
The programming group I'm in is having a problem with Paradox files
being held open at the operating system level by TQuery and/or TTable
controls. We are trying to write code to allow our users to delete an
entire directory of Paradox tablels, but a "sharing violation" is
keeping us from being able to do so. This happens while running on
Windows 95 or NT 4.0, and occurs with 32-bit applications created with
either Delphi 2 or 3. This behavior can be reproduced by performing
the following steps:
1. Create a directory called C:\BADDIR.
2. Create a Paradox 5.0 or 7.0 table named LOCKTBL in C:\BADDIR
containing a primary index and a secondary index (resulting in the
following files: LOCKTBL.db, LOCKTBL.px, LOCKTBL.XG0 and LOCKTBL.YG0).
3. Place a TQuery component on a form.
4. Place "Select * From LOCKTBL" as the SQL text.
5. Place "C:\BADDIR" as the DatabaseName.
6. Run the application calling the query's Open then Close method.
After this sequence-of-events are followed and BEFORE the application
is terminated, if the APP or user attempts to remove the directory
C:\BADDIR, a "Sharing Violation" error will occur. This will NOT
happen on a table with no secondary index.
Also, this will happen by opening and closing a TTable pointed to the
"LOCKTBL."
Does anyone have any suggestions on how to get around this?
Thanks,
Steve Lewis
Applications Developer
Sprint
Atlanta, GA