Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Deleting a Directory Tree

I want to delete and entire directory tree. I do not know how big the directory is, how many sub-dirs that it has, etc. I am not using a form and listing directories, this is some code in a module. All I know is the name of the top directory.

The DOS command to do this is "deltree". If you do a Shell statement to COMMAND.COM, you can run that command on the directory. For instance, the code you would want to do is this: Shell "COMMAND.COM /C DELTREE C:\WINDOWS". (That example could be a bit dangerous, but you get the idea.) I believe there might be API calls to do this, but you'd have to be careful with versioning if you were planning on releasing a 16- and 32-bit version of the program. The hard way to do it (if you wanted to be sure) is to write a recursive directory search that goes through and uses the "Kill" statement and the "RmDir" function to delete any files in a directory and then remove it. You might be able to fake something like this by using a hidden drive/dir/filelist box combination.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date