用实现ASP批量删除目录及文件的代码
(编辑:jimmy 日期: 2024/12/28 浏览:3 次 )
函数过程:
复制代码 代码如下:
<%
'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("目录名")
%>
下一篇:实现纯真IP txt转mdb数据库的方法