Making a new Index: Invalid Index Descriptor (CDX)

I hope you can help me on this one:

I am writing an automatic maintenance utility that runs a background
thread late at night. This thread creates a TTable on the fly and
opens the databases in a directory. Then it deletes all the indexes on
that table and then recreates them according to a configuration file
(that way I can add new indexes without asking my users to exit).

My problem is this: Sometimes, people open the table with FoxPro and
create a CDX. My main Delphi App reacts fine, ignoring the CDX and
using the MDX instead, but when I try to recreate the index with my
background process I get the following error when creating the index:

Invalid index descriptor
Index does not exist
File: \\Server\Directories\File.CDX.

I am already specifying the table type as ttDBase (I am using Delphi
3).

Does anybody know how the DBF knows what kind of CDX to look for? I
need to be able to either switch the DBF header back to MDX
programatically (a-la-foxpro) or be able to recreate my MDX's ignoring
the fact that somebody opened the DBF with foxpro.

My code looks like this:

To Delete my index definitions, I am using:

        for iCounter := 0 to tblTableToReindex.IndexDefs.Count - 1 do
        begin
          strIndexToDelete := lstIndexList.Strings[iCounter];
          tblTableToReindex.DeleteIndex(strIndexToDelete);
          WriteLn(FLogFile,'        Index '+strIndextoDelete+'
Deleted');
        end;

And a little later, to recreate them from the configuration structure

        try

tblTableToReindex.AddIndex(FileToIndex.Indexes.Items[iCounter].Name,

FileToIndex.Indexes.Items[iCounter].Fields,

FileToIndex.Indexes.Items[iCounter].Options);
            tblTableToReindex.IndexDefs.Update;
            WriteLn(FLogFile,'        Index '+
FileToIndex.Indexes.Items[iCounter].Name +
                                     ' created:
'+FileToIndex.Indexes.Items[iCounter].Fields);
          except
            on E: Exception do WriteLn(FLogFile,'        ** ERROR
Creating index '+ FileToIndex.Indexes.Items[iCounter].Name +'!!
['+E.Message+']');
          end;

The config structure "FileToIndex" looks something like:

TFileToIndex = class
    FileName: String;
    Indexes : TIndexDefs;
    Constructor Create;
  end;

David Martinez
dsvito[NoJunkMail]@ix.netcom.com
http://www.geocities.com/SilliconValley/Heights/5212/index.html
Please Delete Spam Protection to email