DeleteFile

DeleteFile

Deletes an error-tolerant file

Syntax

      DeleteFile(<cFileName>) --> <nErrorCode>

Argument

<cFileName> : file name to delete

Returns

<nErrorCod> : Result of delete operation

          DeleteFile() result Codes
          ------------------------------------------------------------------------
          Code    Symb. constants     Definition
          ------------------------------------------------------------------------
           0      NO_DISK_ERR         No error occurs
          -2      ER_FILE_NOT_FOUND   File not found
          -3      ER_PATH_NOT_FOUND   Path not found
          -5      ER_ACCESS_DENIED    Access denied (e.g., file is read-only)
          ------------------------------------------------------------------------

Description

In contrast to FileDelete(), which permits to specify file groups with wildcards, DeleteFile() only accepts specific file names. However, the function avoids all DOS error messages and returns an error code directly to the calling program. This makes error-tolerant erasures in networks possible.

Note

. You can use a drive designator and path name, but no wildcards.

Examples

      .  How NOT to delete a file in a network environment:

      IF FILE ("TEST.DBF")
         * Is it actually possible to delete the file?
         DELETE FILE TEST.DBF
      ENDIF

      .  This is a better way:

      nStatus  :=  DeleteFile("TEST.DBF")
      IF nStatus == 0
         ? "File deleted."
      ELSE
         IF nStatus == -5
            ? "ACCESS DENIED!"
            ? "File in use elsewhere!"
         ENDIF
      ENDIF

Seealso

FileDelete(), RenameFile()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.