dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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: VB5,VB6,VBS
Expertise: beginner
Aug 4, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Delete a folder and all its subfolders

The RmDir command can delete a directory only if it doesn't contain files or sub-directories. If the directory you want to delete does contain other files or, worse, subdirectories it seems that you are forced to use a recursive routine that does the job.

A simpler solution is offered by the DeleteFolder method of the FileSystemObject object, exposed by the Microsoft Scripting Runtime library:


' NOTE: this code requires that you add a reference to the
'       Microsoft Scripting Runtime type library

' delete the C:\TEMP directory and all its sub-directories
Dim fso As New Scripting.FileSystemObject
fso.DeleteFolder "c:\temp"
You can also pass a second argument and set it to True if you want to force the deletion of read-only files:

fso.DeleteFolder "c:\temp", True
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


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

 

 

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