函數過程:
復制代碼 代碼如下:
<%
'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("目錄名")
%>