用实现ASP批量删除目录及文件的代码
时间:2021-07-01 10:21:17
帮助过:26人阅读
函数过程:
代码如下:
<%
'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("目录名")
%>