I tried with
Code: Select all | Expand
if File( cdir+"cust1.dbf" )
erase cdir+"cust1.dbf"
erase cdir+"cust2.dbf"
erase cdir+"cust3.dbf"
erase cdir+"cust4.dbf"
endif
Solution ?
Code: Select all | Expand
if File( cdir+"cust1.dbf" )
erase cdir+"cust1.dbf"
erase cdir+"cust2.dbf"
erase cdir+"cust3.dbf"
erase cdir+"cust4.dbf"
endif
Code: Select all | Expand
// C:\FWH\SAMPLES\SILVERAS.PRG
#Include "Fivewin.Ch"
#Include "Directry.ch"
FUNCTION Main()
LOCAL cDir
cDir := GETCURDIR()
IF SUBS( cDir, LEN( ALLTRIM(cDir ) ) , 1 ) = "\"
cDir := SUBS( cDir, 1 , LEN( ALLTRIM(cDir ) ) - 1 )
ENDIF
LCHDIR( cDir )
// ? cDir
IF FILE( "CUST1.dbf" )
FERASE("CUST4.dbf")
IF FILE( "CUST4.dbf" ) // CHECK only
? "Archivo Bloqueado en RED"
QUIT
ELSE
? "Archivo deletado"
ENDIF
// .or.
// AEVAL(DIRECTORY( "CUST4.DBF" ),{ |aFILE| FERASE(aFILE[F_NAME]) } )
ENDIF
RETURN NIL
// FIN / END
Code: Select all | Expand
FUNCTION Main()
LOCAL DEL_INDICE
//-> Ideia original By Kleyber Derick
DEL_INDICE := DIRECTORY( "*.CDX" )
FOR I = 1 TO LEN( Del_Indice )
FERASE( DEL_INDICE[I][1] )
NEXT I
RETURN NIL
Code: Select all | Expand
if FERASE( cFile ) != 0
? FERROR()
endif
Code: Select all | Expand
// C:\FWH\SAMPLES\SILVERA2.PRG
#include "FiveWin.ch"
#include "fileio.ch"
FUNCTION Main()
IF FErase( "test.txt" ) != F_ERROR
? "File successfully erased"
ELSE
? "File can not be deleted", FERROR()
ENDIF
RETURN NIL
// FIN / END
hb_dbDrop([<cTable>],[<cIndex>])->Nil
gracias, tienes las características y parámetros de esta función? sin embargo ahora parece estar bien con "ferase"carlos vargas wrote:Recordar que existe una función llamada hb_dbdrop la cual elimina la tabla y sus archivos de índices y memo fil asociados.
Code: Select all | Expand
aDIR := DIRECTORY( "C:\DBTMP\*.*", "D" )
IF EMPTY( aDIR )
IF lMkDir( "C:\Dbtmp" )
ELSE
SAYING := "SORRY ... Could not make the directory "+CHR(10)
SAYING += "C:\DBTMP needed to run this Application "+CHR(10)
SAYING += "ABORTING"+CHR(10)
MsgInfo( SAYING )
IF cAUTH = 'Y'
oDLG:End()
ENDIF
CLOSE DATABASES
RETURN(.F.)
ENDIF
ENDIF
// delete trash
FOR i = 1 to LEN( aDIR )
cFILE := ALLTRIM( aDIR[i] [1] )
FERASE( "C:\DBTMP\"+cFILE )
NEXT
FileDelete(<cFileMask>,[<nAttributes>])->lDeleted
Code: Select all | Expand
Cancella_Archivi(".\data\") // on Main.prg
...
return nil
Function Cancella_Archivi(cDir)
local adir := DIRECTORY(cDir+ "*.*", "D" )
local i,cFile
FOR i = 1 to LEN( aDir )
cFILE := ALLTRIM( aDIR[i][1] )
IF FErase(cDir+cFile ) != 0
? FERROR()
endif
NEXT
return nil
Thanks Professor Otto I knew this too but it so happens that I am the administrator of the computer because it is mine and there are no restrictions, delete all the files except two, if the restriction is there why delete the other files?Otto wrote:In the context of Clipper and Harbour programming, the DOS error code 5, as returned by the FERROR() function, indicates "Access denied". This error typically occurs when a program attempts to access a file or directory for which it does not have the necessary permissions, such as attempting to write to a read-only file, accessing a file that is locked by another process, or trying to open a file in a restricted directory.
Otto wrote:In use?
Code: Select all | Expand
#include "fivewin.ch"
REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN
REQUEST DBFCDX
function Main()
RddSetDefault( "DBFCDX" )
SetHandleCount( 100 )
FWNumFormat( "E", .t. )
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
HB_LANGSELECT( "IT" )
HB_CDPSELECT( "ITWIN" )
Cancella_Archivi(".\data\")
DEFINE WINDOW oWnd
@ 2, 2 BUTTON "&App" SIZE 80, 20 ACTION Test()
ACTIVATE WINDOW oWnd MAXIMIZED
RETURN NIL
static Function Cancella_Archivi(cDir)
local adir := DIRECTORY(cDir+ "*.*", "D" )
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
static Function test;return nil