About deleting files
Hi Venci,
Here's a function I use to remove files older than a certain date.
Usage example: WildKillFiles("c:\temp", "*.tmp", Today(), FALSE)
HTH,
Don
FUNCTION WildKillFiles(cPath AS STRING, cMask AS STRING, dKeepDate AS
DATE, lConfirm := TRUE AS LOGIC) AS VOID PASCAL
// clean-up files matching a wild card mask ...
// NB. only files older that Today will be purged
LOCAL I, nMatches AS DWORD
LOCAL pszVar1, pszVar2 AS PSZ
IF ! Right(cPath, 1) == "\"
cPath += "\"
ENDIF
pszVar1 := PSZ(cPath + cMask)
// remove ALL matching files ?
// !!!must prompt by default for safety!!!
IF ! lConfirm ;
.OR. TextBox{, "WARNING: File Delete", cPath + cMask + CRLF + CRLF +
"Confirm delete these files ?", ;
BOXICONHAND + BUTTONYESNO}:Show() == BOXREPLYYES
nMatches := FFCount(pszVar1, FC_NORMAL + FA_COMPRESSED + FC_ARCHIVED)
FOR I := 1 UPTO nMatches
//IF ! DebugMsg(cPath + FName());EXIT;ENDIF
IF dKeepDate > FDate()
// only try to delete files older than date passed
pszVar2 := PSZ(cPath + FName())
IF ! FErase(pszVar2)
// maybe a sharing error
ENDIF
ENDIF
IF ! FNext()
EXIT
ENDIF
NEXT
ENDIF
|