用实现ASP批量删除目录及文件的代码
程序员文章站
2022-06-11 13:16:35
函数过程: 复制代码 代码如下:<% 'del.asp dim fso,tmpfolder,tmpsubfolder,tmpfile...
函数过程:
<%
'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("目录名")
%>
复制代码 代码如下:
<%
'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("目录名")
%>
上一篇: asp 采集实战代码
下一篇: 晚餐吃什么瘦身,这个千万不能吃