Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

any command like DOS's Deltree to delte folders?

Status
Not open for further replies.

rahmanjan

Programmer
Apr 13, 2003
180
0
0
AU
hi all,

I wonder do we have any command like DelTree in DOS which deletes a folder with all its sub-folders and files ... or i have to use FSO and loop through and delete one by one??

regards,

rahman
 
You could always shell the dos command using command /c

COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]

[drive:]path Specifies the directory containing COMMAND.COM file.
device Specifies the device to use for command input and output.
/E:nnnnn Sets the initial environment size to nnnnn bytes.
/P Makes the new command interpreter permanent (can't exit).
/C string Carries out the command specified by string, and then stops.
/MSG Specifies that all error messages be stored in memory. You
need to specify /P with this switch.
 
Dim MySystemObject As New FileSystemObject
Dim sFileFolder as String

sFileFolder = "c:\mydocs\test"
MySystemObject.DeleteFolder sFileFolder, True

The "True" will force the delete even if a file is read-only.
 
I made similar software some years ago.
the concept was to make the deletion recursively: get into a directory, delete all files, than delete the next directory, ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top