DeleteDir

InstallShield 2014 » InstallScript Language Reference

The DeleteDir function deletes a subdirectory. Depending on the value you use in the parameter nFlag, you can delete a subdirectory only if it is empty, delete a subdirectory even if it contains files, or delete an entire root directory. Set nFlag with extreme caution.

Note: Note the following restrictions:

You cannot use DeleteDir to delete the current directory.
You cannot delete files on a network system where you lack the appropriate rights.
DeleteDir cannot delete read-only, hidden, or system files.
If DeleteDir encounters a read-only file, the function can fail after having deleted only some of the files in the subdirectory.

Syntax

DeleteDir( szDir, nFlag );

Parameters

DeleteDir Parameters

Parameter

Description

szDir

Specifies the fully qualified name of the directory to delete.

nFlag

Specifies deletion options. Pass one of the following predefined constants in this parameter:

ALLCONTENTS—Deletes the directory in szDir, including all subdirectories and files beneath it. The directory you are deleting must be a subdirectory and cannot be a root directory of the drive.
ONLYDIR—Deletes the directory in szDir only if it is empty. Otherwise, the function fails.
ROOT—Deletes the directory in szDir even if it is the root directory. If szDir is a root directory, DeleteDir will delete everything on the disk.

Return Values

DeleteDir Return Values

Return Value

Description

0

Indicates that the function successfully deleted the subdirectory.

< 0

Indicates that the function was unable to delete the subdirectory.

See Also