Function procedure:
The code copy is as follows:
<%
'del.asp
dimfso,tmpfolder,tmpsubfolder,tmpfile,tmpfiles
setfso=server.CreateObject("Scripting.FileSystemObject")
subdelfolder(sPath)
If(fso.FolderExists(server.MapPath(sPath)))then
settmpfolder=fso.GetFolder(server.MapPath(sPath))
settmpfiles=tmpfolder.files
foreachtmpfileintmpfiles
fso.DeleteFile(tmpfile)
next
settmpsubfolder=tmpfolder.SubFolders
foreachtmpfolderintmpsubfolder
response.Writespath&"/"&tmpfolder.name&"<br>"
delfolder(spath&"/"&tmpfolder.name)
next
fso.DeleteFolder(server.MapPath(sPath))
endif
endsub
%>
Calling method:
The code copy is as follows:
<%
'Call example
'del.asp is placed on the same level as the directory to be deleted. The directory to be deleted exists and there are several subdirectories and files under it. You must have modification permissions for the directory.
delfolder("Directory Name")
%>