DELETE FILE issue

DELETE FILE issue

Postby TimStone » Wed Aug 17, 2016 9:11 pm

In my application I have a program to recreate indexes for all of my files. Here is a sample code:

Code: Select all  Expand view
    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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: DELETE FILE issue

Postby Enrico Maria Giordano » Wed Aug 17, 2016 9: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: DELETE FILE issue

Postby TimStone » Wed Aug 17, 2016 9: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: DELETE FILE issue

Postby Rick Lipkin » Thu Aug 18, 2016 2:02 pm

Tim

Why not use Ferase() ??

Code: Select all  Expand view


// 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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: DELETE FILE issue

Postby TimStone » Thu Aug 18, 2016 9: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 97 guests