A very simple to delete a directory and the entire files and folders in its subdirectory structure (Tree).
It uses Dir object,
Dim tempor As String, pos As Integer ' declarations
' function
Sub DelFiles(path)
pos = 0
tempor = Dir(path + "\*.*", 22)
Do While tempor < > ""
If tempor < > "." And tempor < > ".." Then
If (GetAttr(path + "\" + tempor) And 16) = 0 Then
SetAttr path + "\" + tempor, 0
Kill path + "\" + tempor
Else
DelFiles (path + "\" + tempor)
tempor = Dir(path + "\*.*", 22)
End If
End If
tempor = Dir
Loop
RmDir path
End Sub
' function
Sub DelFiles(path)
pos = 0
tempor = Dir(path + "\*.*", 22)
Do While tempor < > ""
If tempor < > "." And tempor < > ".." Then
If (GetAttr(path + "\" + tempor) And 16) = 0 Then
SetAttr path + "\" + tempor, 0
Kill path + "\" + tempor
Else
DelFiles (path + "\" + tempor)
tempor = Dir(path + "\*.*", 22)
End If
End If
tempor = Dir
Loop
RmDir path
End Sub
path
Views 1,202
Downloads 471
CodeID
DB ID