I tried with
- Code: Select all Expand view
- if File( cdir+"cust1.dbf" )
erase cdir+"cust1.dbf"
erase cdir+"cust2.dbf"
erase cdir+"cust3.dbf"
erase cdir+"cust4.dbf"
endif
But not erase nothing
Solution ?
if File( cdir+"cust1.dbf" )
erase cdir+"cust1.dbf"
erase cdir+"cust2.dbf"
erase cdir+"cust3.dbf"
erase cdir+"cust4.dbf"
endif
// 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
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
if FERASE( cFile ) != 0
? FERROR()
endif
// 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
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.
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
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
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?
#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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 83 guests