erase files - Resolved!!

User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: erase files

Post by Silvio.Falconi »

Otto wrote:Who created the cdx files. Which user account.
I created the files cdx with account administrator , It Is the last One account on my PC
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
solving
Posts: 65
Joined: Fri Jun 05, 2009 7:55 am
Location: Sicily ( ct ) - Italy

Re: erase files

Post by solving »

LOCAL xPath := "C:\PDF\"

* --- Elimina File che Iniziano con CLI_...PDF
AEVAL(DIRECTORY(xPath + "CLI_*.PDF"),{|aFile|FERASE(xPath + aFile[F_NAME])} )


nel tuo comando :
cFILE := ALLTRIM( aDIR[1] )

fai un display della variabile cFILE se comprende il path completo + \ , es. c:\mydir\temp2.cdx o vedi solo temp2.cdx
User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: erase files

Post by Silvio.Falconi »

Ho messo un trace msginfo(ferror,cfile)
Tutti e due i messaggi viene visualizzato l'errore 5 , il primo mi dà "." e il secondo ".." è sta cosa che non ho capito.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: erase files

Post by Otto »

Insert a msginfo() before you delete the files and check with "Resource Monitor" the "Assoiated Handles" of your file.

Open the Start menu, type "Resource Monitor" and press Enter.
Switch to the "CPU" tab.
Expand the "Associated Handles" section in the lower panel.
In the search field of the "Associated Handles" section, enter the name of the file you want to check. If the file is being used, it will appear in the list along with the process using it.

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
solving
Posts: 65
Joined: Fri Jun 05, 2009 7:55 am
Location: Sicily ( ct ) - Italy

Re: erase files

Post by solving »

la sintassi :
aDir := DIRECTORY(cDir+ "*.*", "D" )
include nell'array anche i "." e ".."
aDIR[1,1] = "."
aDIR[2,1] = ".."

se usi :
aDir := DIRECTORY(cDir+ "*.*" ) , non verranno inglobati "." e ".."

se usi il parametro "D" allora devi controllare il contenuto dell'array

IF cFile <> "." .OR. cFile <> ".."

IF FErase(cDir+cFile ) != 0
? FERROR()
ENDIF

ENDIF

consiglio 1 : senza parametro "D"
consiglio 2 : metti il path -> cDir + cFile
User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: erase files

Post by Silvio.Falconi »

ecco dov'era l'errore il parametro D

static Function Cancella_Archivi(cDir)
local adir := DIRECTORY(cDir+ "*.*" )
local i,cFile

FOR i = 1 to LEN( aDir )
cFILE := ALLTRIM( aDIR[1] )
IF FErase(cDir+cFile ) != 0
Msginfo( FERROR() ,cfile)
endif
NEXT
return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Post Reply