Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDelete a directory and everything it contains using the File System Object
KeywordsFile System Object, file, directory, dir
CategoriesAlgorithms, Files & Directories
 
Use the File System Object's DeleteFolder method. Note that this permanently removes the directory and everything it contains, it does not move it to the wastebasket.
 
' If the user presses the Delete key, delete the
' currently displayed file.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As _
    Integer)
Dim dir_name As String
Dim fso As FileSystemObject

    If KeyCode = vbKeyDelete Then
        ' Make the user confirm.
        dir_name = DirList.List(DirList.ListIndex)
        If MsgBox("Permanently delete directory " & _
            dir_name & " and everything it contains?", _
            vbQuestion Or vbYesNo, _
            "Delete Directory?") = vbNo _
                Then Exit Sub

        ' Delete the directory.
        Set fso = New FileSystemObject
        fso.DeleteFolder dir_name, True

        DirList.Refresh
    End If
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated