FileSystemObject.DeleteFolder Method (VB6) |
Named Arguments
Yes
Syntax
oFileSysObj.DeleteFolder FileSpec[, Force]
oFileSysObj
Use: Required
Data Type: FileSystemObject object
Any object variable returning a FileSystemObject object.
FileSpec
Use: Required
Data Type: String
The name and path of the folders to delete.
Force
Use: Optional
Data Type: Boolean
If set to True, the read-only flag on a file is ignored and the file deleted.
Description
Removes a given folder and all its files and subfolders.
Rules at a Glance
FileSpec can contain wildcard characters as the final path component.
FileSpec can't end with a path separator.
FileSpec can be a relative or absolute path.
If any of the files within the specified folders are open, the method fails with a Permission Denied error.
The DeleteFolder method deletes all contents of the given folder, including other folders and their contents.
The default setting for Force is False.
If Force is False, and any of the files in the folders are read-only, the method fails.
If the specified folder can't be found, the method fails.
Programming Tips and Gotchas
If an error occurs while deleting more than one file or folder, the DeleteFolder method exits immediately, thereby leaving the rest of the folders or files undeleted. There is also no roll-back facility to undo the deletions prior to the error.
DeleteFolder permanently deletes folders and their contents; it doesn't move them to the Recycle Bin.
If the user has adequate rights, the source ...
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.