Problemas com Erase e Delete File.

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Maurício Elias
Usuário Nível 3
Usuário Nível 3
Mensagens: 304
Registrado em: 12 Mai 2005 08:48

Problemas com Erase e Delete File.

Mensagem por Maurício Elias »

Bom dia pessoal.

No meu Sistema, utilizo o Erase e Delete File. Mas parece que não funciona bem com o Harbour. Hora exclui, hora não.
Tem algum outro comando que posso utilizar ?
Abraços.
_______
Maurício
yugi386
Usuário Nível 2
Usuário Nível 2
Mensagens: 82
Registrado em: 24 Jul 2008 10:36
Localização: Minas Gerais

Problemas com Erase e Delete File.

Mensagem por yugi386 »

Use a função fErase():

Código: Selecionar todos

fErase("arquivo texto.txt")
att,

Yugi
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Problemas com Erase e Delete File.

Mensagem por Itamar M. Lins Jr. »

Se ora exclui, ora não exclui vc precisa pegar o erro e saber qual é o motivo.

Use ferror() p/ saber qual é o problema.

Código: Selecionar todos

FERROR()
 Test for errors after a binary file operation
------------------------------------------------------------------------------
 Syntax

     FERROR() --> nErrorCode

 Returns

     FERROR() returns the DOS error from the last file operation as an
     integer numeric value.  If there is no error, FERROR() returns zero.

     FERROR() Return Values
     ------------------------------------------------------------------------
     Error   Meaning
     ------------------------------------------------------------------------
     0       Successful
     2       File not found
     3       Path not found
     4       Too many files open
     5       Access denied
     6       Invalid handle
     8       Insufficient memory
     15      Invalid drive specified
     19      Attempted to write to a write-protected disk
     21      Drive not ready
     23      Data CRC error
     29      Write fault
     30      Read fault
     32      Sharing violation
     33      Lock Violation
     ------------------------------------------------------------------------

 Description

     FERROR() is a low-level file function that indicates a DOS error after a
     file function is used.  These functions include FCLOSE(), FCREATE(),
     FERASE(), FOPEN(), FREAD(), FREADSTR(), and FRENAME().  FERROR() retains
     its value until the next execution of a file function.

     Warning!  This function allows low-level access to DOS files and
     devices.  It should be used with extreme care and requires a thorough
     knowledge of the operating system.

 Examples

     .  This example tests FERROR() after the creation of a binary
        file and displays an error message if the create fails:

        #include "Fileio.ch"
        //
        nHandle := FCREATE("Temp.txt", FC_NORMAL)
        IF FERROR() != 0
           ? "Cannot create file, DOS error ", FERROR()
        ENDIF
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Maurício Elias
Usuário Nível 3
Usuário Nível 3
Mensagens: 304
Registrado em: 12 Mai 2005 08:48

Problemas com Erase e Delete File.

Mensagem por Maurício Elias »

Olá pessoal, bom dia.
Com o FErase() tb deu problemas.
Mas, na vdd, era um erro meu, que não acontecia na compilação BLinker.
Eu gero um arquivo " Set printer to Arq.TXT ", mas não estava fechando o processo com o " Set Printer to ". Ai mandava apagá-lo. Resolvido. Obrigado a todos.
Abraços.
_______
Maurício
Responder