Page 2 of 2

Re: erase files

PostPosted: Thu Jan 25, 2024 5:31 pm
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

Re: erase files

PostPosted: Thu Jan 25, 2024 6:02 pm
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[i][1] )

fai un display della variabile cFILE se comprende il path completo + \ , es. c:\mydir\temp2.cdx o vedi solo temp2.cdx

Re: erase files

PostPosted: Thu Jan 25, 2024 6:09 pm
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.

Re: erase files

PostPosted: Thu Jan 25, 2024 7:45 pm
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

Re: erase files

PostPosted: Fri Jan 26, 2024 10:42 am
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

Re: erase files

PostPosted: Fri Jan 26, 2024 11:13 am
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[i][1] )
IF FErase(cDir+cFile ) != 0
Msginfo( FERROR() ,cfile)
endif
NEXT
return nil