Use the recursive algorithm to implement the ASP program with FSO's traversal of directory and files on a path on the hard

zhaozj2021-02-11  167

Use the recursive algorithm to realize the traversal of the directory and files under the hard disk on a path on the hard disk.

Hu Lei

Due to work needs, be a traversal program on the hard disk, so I want to use ASP to implement this feature.

I wrote this program. The program is mainly used to the ASP's FileSystemObject file system object. can

As a learning program for friends who want to understand and learn FSO.

File name Bianli.asp

<% @Language = VBScript%> <% Function Bianli (PATH) DIM FSO 'FSO Object DIM OBJFOLDER' Folder Object DIM OBJSUBFOLDERS 'Subfolder Set DIM ObjSubfolder' Subfolder Object DIM Objfiles 'File Dim Objfile' file object

set fso = server.CreateObject ( "scripting.filesystemobject") on error resume next set objFolder = fso.GetFolder (path) 'Create a folder object set objSubFolders = objFolder.Subfolders' sub-folders that you create an object for each objSubFolder in objSubFolders nowpath = path "/" objSubFolder.name Response.Write nowpath set objFiles = objSubFolder.Files for each objFile in objFiles Response.Write "
---" Response.Write objFile.name next Response.Write "

"Bianli (nowPath) 'call recursive next set objfolder = Nothing set = nothing end function%> <% bianli (" d: ")' calls the bianli () function, here is traversal D: Disc%>

The above program runs through the Win2000 Server.

转载请注明原文地址:https://www.9cbs.com/read-5744.html

New Post(0)