//////// VERIFY A FILE EXISTENCE //////////|||COL|||2

I'm currently developing a program where I need to assign to a TTable component a DB File which changes its name ( due to another application ).

I Know all the names that file can have but I don't know how to verify wich one it has when I run the program so I can assign it to the TableName propertie of the TTAble component.

Can anyone help me ?

Thanks , Bruno Maia


  • If you have 3 possible DB files (f1.db,f2.db,f3.db) to assign to ttable component named tbl1 then try this:


    if fileexists(f1.db) then

    tbl1.tablename := f1


    if fileexists(f2.db) then

    tbl1.tablename := f2.db

    else tbl1.tablename := f3.db;


  • You have basically two possibilities:

    1. You can _try_ to open the DB file and if

    an exception occurs, you know that this

    is not the file.

    2. You can set I/O error checking to off: {$I-},

    try to open the file via AssignFile/Reset,

    and test the IOResult variable.

    If IOResult=0 then it is OK!

    I personally use the second possibility, because

    I am used to it since the good old years of

    Turbo Pascal.

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!