当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用实现ASP批量删除目录及文件的代码

ASP
asp 实现对SQL注入危险字符进行重编码处理的函数
asp下实现对HTML代码进行转换的函数
asp 验证用户名是否包含有非常字符的函数
ASP通用分页样式函数代码
asp 生成任意英文+数字位数长度的随机码函数
asp 取得中文句子头一个字的大写拼音字母的函数
asp实现计算两个时间内的工作日的函数
asp实现过滤关键字的函数
asp实现限制搜索的关键字的函数
asp动态include文件,方便多模板的实现
推荐的用Asp实现屏蔽IP地址访问的代码
XDOWNPAGE ASP版本 分页类
飞云防CC攻击ASP程序代码插件
定期自动运行ASP程式的代码
ASP下Cookie操作的详细讲解
再发几个ASP不错的函数
比较不错的asp模板引终极讲解(WEB开发之ASP模式)
ip138之asp小偷程序代码
在VBScript中实现-函数/方法名作为参数传入另一个函数
asp实现批量插入表单中的数据到数据库的方法

用实现ASP批量删除目录及文件的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 62 ::
收藏到网摘: n/a

函数过程:
复制代码 代码如下:

<%
'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("目录名")
%>