FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour DELETE FILE issue
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
DELETE FILE issue
Posted: Wed Aug 17, 2016 09:11 PM
In my application I have a program to recreate indexes for all of my files. Here is a sample code:

Code (fw): Select all Collapse
    DELETE FILE evemnt.cdx
    oDB := tdata():new(, "evemnt",, .f. )
    IF oDB:use()
        oDB:createIndex( "evemnt", "upper(vehlic)",,, .t., 10 )
    ENDIF
    oDB:close()


The strategy is to delete the existing CDX file, and then re-create a new one. It has worked well for many years. Recently, apparently the DELETE FILE command is not working. If the CDX is corrupted, it won't reindex and it will fail.

Here is my question. Doesn't DELETE FILE honor the DEFAULT PATH or do I actually need to specify the full path ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: DELETE FILE issue
Posted: Wed Aug 17, 2016 09:38 PM
From Clipper NG:

SET DEFAULT and SET PATH do not affect DELETE
FILE. The file is deleted from disk only if found in the current DOS
directory or in the directory explicitly specified as part of the
filename.


EMG
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: DELETE FILE issue
Posted: Wed Aug 17, 2016 09:52 PM

I suspected that ... so I modified the code ...

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: DELETE FILE issue
Posted: Thu Aug 18, 2016 02:02 PM
Tim

Why not use Ferase() ??

Code (fw): Select all Collapse
// put at the top of your Main() program
// where .exe started from is default directory //

cFILE  := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

SET DEFA to ( cDEFA )

...
...

//--------------
Func YourFunction()

cDefa := set(7) // gets default file location from app if you specified Set Defa to ...  in your app.

Frease( cDefa+"\Your.Cdx" )


Rick Lipkin
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: DELETE FILE issue
Posted: Thu Aug 18, 2016 09:20 PM

Rick,

It wasn't a problem ... just had not included the path.

Now using:

DELETE FILE ( cPath + "abc.cdx" )

cPath is the default folder and it is a public defined at startup.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion