Function procedure:
Copy Code code as follows:
<%
' Del.asp
Dim fso,tmpfolder,tmpsubfolder,tmpfile,tmpfiles
Set Fso=server. CreateObject ("Scripting.FileSystemObject")
Sub Delfolder (spath)
If (FSO). FolderExists (server. MapPath (spath)) Then
Set TMPFOLDER=FSO. GetFolder (server. MapPath (spath))
Set Tmpfiles=tmpfolder.files
For each tmpfile in Tmpfiles
Fso. DeleteFile (Tmpfile)
Next
Set Tmpsubfolder=tmpfolder. Subfolders
For each tmpfolder in Tmpsubfolder
Response. Write spath& "/" &tmpfolder.name& "<br>"
Delfolder (spath& "/" &tmpfolder.name)
Next
Fso. DeleteFolder (server. MapPath (spath))
End If
End Sub
%>
Call Method:
Copy Code code as follows:
<%
' Call example
' del.asp to the same level as the directory you want to delete, the directory you want to delete exists and has several subdirectories and files under it, to which you have permission to modify.
Delfolder ("Directory Name")
%>