by Dan Liu (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 22nd October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This function will delete all the folder(s) and its contents under the root folder. All you need to do is to pass in the Path as a Parameter.
Dim MyFile, MyPath, MyName
Dim Fs As Scripting.FileSystemObject
Set Fs = CreateObject("Scripting.FileSystemObject")
' Display the names that represent directories.
MyPath = inPath ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
MsgBox MyPath & MyName
Fs.DeleteFolder (MyPath & MyName)
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop
End Sub
No comments have been posted about This function will delete all the folder(s) and its contents under the root folder. All you need to. Why not be the first to post a comment about This function will delete all the folder(s) and its contents under the root folder. All you need to.