4D v16.3

DELETE FOLDER

Home

 
4D v16.3
DELETE FOLDER

DELETE FOLDER 


 

DELETE FOLDER ( folder {; deleteOption} ) 
Parameter Type   Description
folder  String in Name or full path of the folder to be deleted
deleteOption  Longint in Folder deletion option

The DELETE FOLDER command deletes the folder whose name or full path has been passed in folder.

By default, for security reasons, if you omit the deleteOption parameter, DELETE FOLDER only allows empty folders to be deleted. If you want the command to be able to delete non-empty folders, you must use the deleteOption parameter. In deleteOption, you can pass one of the following constants, found in the "System Documents" theme:

Constant Type Value Comment
Delete only if empty Longint 0 Deletes folder only when it is empty
Delete with contents Longint 1 Deletes folder along with everything it contains
  • When Delete only if empty (0) is passed or if you omit the deleteOption parameter:
    • The folder specified in the folder parameter is only deleted if it is empty; otherwise, the command does nothing and an error -47 (The file is already open, or the folder is not empty) is generated.
    • If the folder specified does not exist , the error -120 (Tried to access a file by using a pathname that specifies a non existing directory) is generated.
  • When Delete with contents (1) is passed:
    • The folder along with all of its contents are deleted.
      Warning:
      Even when this folder and/or its contents are locked or set to read-only, if the current user has suitable access rights, they are still deleted.
    • If this folder, or any of the files it contains, cannot be deleted, deletion is aborted as soon as the first inaccessible element is detected, and an error(*) is returned. In this case, the folder may be only partially deleted. When deletion is aborted, you can use GET LAST ERROR STACK command to retrieve the name and path of the offending file.
    • If the folder specified does not exist, the command does nothing and no error is returned.

      (*) under Windows: -54 (Attempt to open locked file for writing)
      under OS X: -45 (The file is locked or the pathname is not correct)

You can intercept these errors using a method installed by the ON ERR CALL command.



See also 


DELETE DOCUMENT

 
PROPERTIES 

Product: 4D
Theme: System Documents
Number: 693

The OK variable is changed by the commandThis command modifies the Error system variableThis command can be run in preemptive processes

 
HISTORY 

Created: 4D v6.7
Modified: 4D v15 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)