Description:-

This is used to delete a directory on disk or in memory if you have the required permissions to run this function.

directoryDelete( path );

Attributes:-

path:- This is a required attribute, the path of a directory to be deleted on an absolute on-disk or in-memory location. Alternatively, you can specify the IP address as in the bellow example:
directoryCreate( "//192.168.0.1/new_disc/test" );

recurse:- This is a non-required attribute, the default value is falseSet it as true if you want the directory and the sub-directories to be deleted. If the directory(being deleted) has sub-directories and you set recurse to false, an exception occurs.

Example:-

In this example, we will delete this d:\files\documents directory and then check if this exists or not.

<cfscript>
    if ( !directoryExists( "d:\files\documents" ) ){
        directoryCreate( "d:\files\documents" );
    }

    writeOutput( "Before Delete: #directoryExists( "d:\files\documents" )#" );

    directoryDelete( "d:\files\documents" );

    writeOutput( "After Delete: #directoryExists( "d:\files\documents" )#" );
</cfscript>

Result:-

Before Delete: YES
After Delete: NO
After Rename new: YES

In our system, we delete this d:\files\documents directory and we check if our directory exists before deleting and also check after deleting to confirm whether this directory is deleted or not.