用实现ASP批量删除目录及文件的代码
时间:2021-08-01 08:56:11|栏目:ASP代码|点击: 次
函数过程:
<%
'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编程入门进阶(十八):FSO组件之文件操作(上)
栏 目:ASP代码
下一篇:sql 存储过程分页
本文标题:用实现ASP批量删除目录及文件的代码
本文地址:http://www.codeinn.net/misctech/163259.html