Folder.Delete

Folder.Delete ( 

string Folder )

Example 1

Folder.Delete("C:\\Stored");

Deletes a folder called "Stored" from the user's C: drive.

Example 2

Folder.Delete(_ProgramFilesFolder.."\\Flashy");

Deletes a folder called "Flashy" from the user's Program Files folder.

Note: _ProgramFilesFolder is a built-in variable that contains the path to the user's Program Files folder.

Example 3

-- Get the path to the user's My Documents folder.
myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);

-- Delete the folder.
Folder.Delete(myDocsFolder.."\\Partial Backup");

-- Check to see if any errors were generated from the delete.
error = Application.GetLastError();

-- Check to see if the deletion failed due to files being present.
if error == 2203 then
    -- Remove all of the contents of the folder.
    File.Delete(myDocsFolder.."\\Partial Backup\\*.*", true, false, false, nil);

    -- Attempt to remove the folder again.
    Folder.Delete(myDocsFolder.."\\Partial Backup");

    -- Check to see if the action failed.
    error = Application.GetLastError();

    -- Notify the user that the folder couldn't be deleted.
    if (error ~= 0) then
        Dialog.Message("Error", "The folder could not be deleted.", MB_OK, MB_ICONEXCLAMATION);
    end
end

Tries to delete the folder called "Partial Backup" in the user's My Documents folder. If the action failed because the folder was not empty, all of the files will be deleted. After the files have been deleted, another attempt to remove the folder is performed.

See also:  Related Actions