<% '建立文件系统对象 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 sub_folder_name=each_sub_folder.name '目录名 sub_folder_path=c_path&""&each_sub_folder.name set cur_sub_folder=file_system.getfolder(sub_folder_path) '建立检索目录下的文件对象集合 set sub_files=cur_sub_folder.files '遍历文件对象集合 for each each_file in sub_files name=each_file.name'取文件名 next
next
*********************************************************************************************************
使用递归
set file_system=createobject("scripting.filesystemobject")
sub getFile(c_path) set cur_folder=file_system.getfolder(c_path) set sub_folders=cur_folder.subfolders
for each each_sub_folder in sub_folders set sub_files=cur_sub_folder.files for each each_file in sub_files name=each_file.name'取文件名 next sub_folder_name=each_sub_folder.name '目录名 sub_folder_path=c_path&""&each_sub_folder.name sub getFile(sub_folder_path) next
end sub
********************************************************************************
function search_folder(c_path) '目录检索函数 '建立文件系统对象 set file_system=createobject("scripting.filesystemobject") '建立建立当前目录对象 set cur_folder=file_system.getfolder(c_path) '建立当前目录的子目录对象集合 set sub_folders=cur_folder.subfolders '搜索当前目录中的文件 p=search_file(c_path) '对子目录集合进行遍历 for each each_sub_folder in sub_folders '确定子目录的属性为普通子目录 sub_c_path=c_path&""&each_sub_folder.name '调用文件检索函数对当前子目录下的文件进行字符串匹配检索 p=search_file(sub_c_path) '递归检索当前子目录的下一级目录 p=search_folder(sub_c_path) next '清除所有服务器端对象 set sub_files=nothing set each_sub_folder=nothing set sub_folders=nothing set cur_folder=nothing set file_system=nothing end if end function
**********************************************
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 name=each_file.name'取文件名 next %>
|