|
<%
' Set up file system objects
Set File_system=createobject ("Scripting.FileSystemObject")
' Set up the current directory object
Set Cur_folder=file_system.getfolder (C_path)
' Create a collection of subdirectory objects for the current directory
Set Sub_folders=cur_folder.subfolders
' Traversal of subdirectories collection
For each each_sub_folder in Sub_folders
Sub_folder_name=each_sub_folder.name ' Directory name
sub_folder_path=c_path& "" &each_sub_folder.name
Set Cur_sub_folder=file_system.getfolder (Sub_folder_path)
' Set up a collection of file objects under the Retrieve directory
Set Sub_files=cur_sub_folder.files
' Traverse the collection of file objects
For each each_file in Sub_files
Name=each_file.name ' fetch filename
Next
Next
*********************************************************************************************************
Using recursion
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 ' fetch filename
Next
Sub_folder_name=each_sub_folder.name ' Directory name
sub_folder_path=c_path& "" &each_sub_folder.name
Sub GetFile (Sub_folder_path)
Next
End Sub
********************************************************************************
function Search_folder (c_path) ' Directory retrieval functions
' Set up file system objects
Set File_system=createobject ("Scripting.FileSystemObject")
' Set up the current directory object
Set Cur_folder=file_system.getfolder (C_path)
' Create a collection of subdirectory objects for the current directory
Set Sub_folders=cur_folder.subfolders
' Search for files in the current directory
P=search_file (C_path)
' Traversal of subdirectories collection
For each each_sub_folder in Sub_folders
' Determines that the attributes of subdirectories are normal subdirectories
sub_c_path=c_path& "" &each_sub_folder.name
' Call the file retrieval function to retrieve the string matching files under the current subdirectory
P=search_file (Sub_c_path)
' recursively retrieves the next level of directory for the current subdirectory
P=search_folder (Sub_c_path)
Next
' Clears all server-side objects
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
' Establish a collection of file objects in the retrieved directory
set sub_files=cur_folder.files
' traverse the collection of file objects
for each each_file in Sub_files
Name=e Ach_file.name ' fetch filename
next
%>
|