DeleteDirectory

Deletes a directory and optionally deletes subdirectories

Member of namespace

FileIO

Syntax

bool DeleteDirectory (string Directory, bool Recursive, bool FailureReturnValue)

Parameters

string Directory

bool Recursive

bool FailureReturnValue

Parameters

Directory: The path of the directory to delete.

Recursive: True deletes the directory and all files and subdirectories. False deletes only the directory and requires that the directory is empty.

FailureReturnValue: True causes the action to always return True, even if the delete fails. False causes the action to return False if the directory delete fails.

Smart parameters are supported for the directory path.

Returns

Always returns True if the directory is deleted.

If a failure occurs when you delete a directory, the action returns the value of FailureReturnValue. This result lets you determine whether the action returns True or False on a directory failure. Depending on the application, it might make sense to ignore a delete failure so this action can be set to always return True.

Level

Any level.

Details

Deletes the specified directory and can optionally delete subdirectories.
Example
DeleteDirectory("C:\MyDir1\MyDir2",True,True)       

This example deletes MyDir2 and all files and subdirectories. If the delete fails, the action still returns True.