Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Delete a folder and all its subfolders

Total Hit ( 3340)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
' 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:

Click here to copy the following block
fso.DeleteFolder "c:\temp", True


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.