函数过程:
复制代码代码如下:
<%
'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
%>
调用方法:
复制代码代码如下:
<%
'调用例子
'del.asp放到要删除的目录同一层,要删除的目录存在且其下有若干子目录和文件,要对该目录具有修改权限。
delfolder("目录名")
%>