Traverse all files under the directory

zhaozj2021-02-12  201

PHP

code:

<%

Function Bianli (PATH)

SET FSO = Server.createObject ("scripting.filesystemObject")

ON Error ResMe next

Set objfolder = fso.getfolder (PATH)

Set objsubfolders = Objfolder.subfolders

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) 'recursive

NEXT

Set objfolder = Nothing

Set objsubfolders = Nothing

SET FSO = Nothing

END FUNCTION

%>

<%

Bianli ("D:") 'Traversing D: Disc

%>

<% Function bianli (path) set fso = server.CreateObject ( "scripting.filesystemobject") on error resume nextset objFolder = fso.GetFolder (path) set objSubFolders = objFolder.Subfoldersfor each objSubFolder in objSubFolders nowpath = path "/" objSubFolder.nameResponse.Write nowpathset objFiles = objSubFolder.Filesfor each objFile in objFilesResponse.Write "
---" Response.Write objFile.namenextResponse.Write "

" bianli (nowpath) 'recursive next set objFolder = nothingset objSubFolders = NothingSet Fso = Nothingend Function%> <% Bianli ("D:") 'Traversing D: Disc%>

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

New Post(0)