<%
data=request.form("search_data")
' 从FORM变量集得到要查询的文件名称所要包含的字符串
p=search_folder(data,"http://jack/cgi-bin","c:\intels\wwwroot\cgi-bin")
' 调用函数查询目标查询目录下的所有子目录(所有子树),方法:search_folder(要查询的字符串,查询目标的虚拟绝对路径,查询目标的真实绝对路径)
%>
<script language="vbscript" RUNAT=SERVER>
function search_folder(search_data,v_path,c_path)
dim file_system,cur_folder,sub_folders,sub_files
' 目录检索函数
if not isempty(search_data) and len(search_data)>0 then
' 确定查询字符串有效非空
set file_system=createobject("scripting.filesystemobject")
' 建立文件系统对象
set cur_folder=file_system.getfolder(c_path)
' 建立建立当前目录对象
set sub_folders=cur_folder.subfolders
' 建立当前目录的子目录对象集合
for each each_sub_folder in sub_folders
' 对子目录集合进行遍历
if each_sub_folder.attributes=16 then
' 确定子目录的属性为普通子目录
sub_v_path=v_path&"/"&each_sub_folder.name
sub_c_path=c_path&""&each_sub_folder.name
'得到当前的子虚拟绝对路径与真实绝对路径,默认子目录与子虚拟目录级别名称完全相同
p=search_file(search_data,sub_v_path,sub_c_path)
' 调用文件检索函数对当前子目录下的文件进行字符串匹配检索
p=search_folder(search_data,sub_v_path,sub_c_path)
' 递归检索当前子目录的下一级目录
end if
next
set each_sub_folder=nothing
set sub_folders=nothing
set cur_folder=nothing
set file_system=nothing
' 清空
end if
end function
--------------------------------------------------------------------------------------------------------------------------------
function search_file(search_data,v_path,c_path)
dim file_system,sub_files,sub_file_v_path,sub_out_v_path
' 文件匹配检索函数
if not isempty(c_path) then
' 确认路径不为空
set file_system=createobject("scripting.filesystemobject")
set cur_folder=file_system.getfolder(c_path)
set sub_files=cur_folder.files
' 建立检索目录下的文件对象集合
for each each_file in sub_files
' 遍历文件对象集合
if instr(each_file.name,search_data)<>0 then
' 匹配字符串与文件名
sub_file_v_path=v_path&"/"&each_file.name
' 建立可用链接,输出匹配文件
sub_out_v_path=Replace(sub_file_v_path," ","%20")
' 替换路径及文件名中的空格,以便系统确定路径
response.write("<p><a
href="&sub_out_v_path&">"&sub_file_v_path&"</a>")
end if
next
set sub_out_v_path=nothing
set sub_file_v_path=nothing
set each_file=nothing
set sub_files=nothing
set file_system=nothing
end if
end function
</script>
在ASP中,FSO的意思是File System Object,即文件系统对象。我们将要操纵的计算...
一、将VS2019中已有的项目与远程库进行连接 0.GitHub中创建远程库 首先在GitHub...
本文转载自微信公众号「猿天地」,作者尹吉欢。转载本文请联系猿天地公众号。 当...
温故而知新 数组是一种线性表数据结构,它用一组连续的内存空间,来存储一组具有...
前言 上次咱们学习了如何使用Go操作Mysql,并且实现了简单的增删改查。 但是相对...
由于自己的公司的项目需要调用视频地址 1:当为链接时:直接在播放器用数据库查...
安装 安装CKEditor是一件容易的工作,只需要按照下面的简单步骤就可以完成。 1....
声明本文只作学习研究禁止用于非法用途否则后果自负如有侵权请告知删除谢谢 文章...
本文实例为大家分享了js面向对象方式实现拖拽的具体代码,供大家参考,具体内容...
在用java进行web业务开发的时候,对于页面上接收到的参数,除了极少数是步可预知...