This function will delete all the folder(s) and its contents under the root folder. All you need to
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.
Rate This function will delete all the folder(s) and its contents under the root folder. All you need to
(2(2 Vote))
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
This function will delete all the folder(s) and its contents under the root folder. All you need to Comments
No comments yet — be the first to post one!
Post a Comment