xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

DELETE FILE

Deletes a file from disk.

Syntax

DELETE FILE <cFilename>
ERASE <cFilename>

Arguments

<cFilename>
This is name of the file to delete. It must include path and file extension and can be specified as a literal file name or as a character expression enclosed in parentheses. The path can be omitted from <cFilename> when the file resides in the current directory.

Description

DELETE FILE, or its synonym ERASE, is a file command that deletes a file from disk. When <cFilename> does not include drive and directory information, the file is searched only in the current directory. Directories specified with SET DEFAULT or SET PATH are ignored by this command.

The file must be closed before it can be deleted.

When the file <cFilename> is not found or when it is in use, either a runtime error is generated, or a file error occurs that can be queried with function FError().

Info

See also:CLOSE, CurDir(), FErase(), FError(), File(), FRename(), RENAME, USE
Category: File commands
Source:rtl\philes.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example deletes a group of index files in the current directory.

   #include "Directry.ch"

   PROCEDURE Main
      LOCAL aDir := Directory( "*.ntx" )
      LOCAL i, imax := Len( aDir )

      FOR i:=1 TO imax
         DELETE FILE ( aDir[i,F_NAME] )
      NEXT
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe