asp 显示目录和子目录下面所有文件的 函数源码
asp 循环限时目录下面素有文件的函数 再通过递归显示子目录下面的文件
<%
dim myfilename()redim myfilename(0)
set fs=Server.CreateObject("Scripting.FileSystemObject")
sub showfile(thefolder)
set fd=fs.getfolder(thefolder)for each myfile in fd.files
i=ubound(myfilename)
myfilename(i)=fd.path & "\" & myfile.name
redim Preserve myfilename(i+1)
next
for each myfolder in fd.SubFolders '递归记录其它文件夹的文件
call showfile(fd.path & "\" & myfolder.name)
next
end sub
thefolder="F:\zzzyk.com" '在此指定要搜索的文件夹绝对路径,要确定匿名用户有访问的权限,否则会出错
call showfile(thefolder) '过程调用后,查到的文件名包括路径名保存在myfilename数组,
'共ubound(myfilename)个,下标分布在0至ubound(myfilename)-1;'以下示例把找到文件显示出来
response.write("共找到" & ubound(myfilename) & "个文件<br>")
for i=0 to ubound(myfilename)-1
response.write(i+1 & "--" & myfilename(i) & "<br>")
next
%>