Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing the folders and only folders?

Status
Not open for further replies.

pha2er

Programmer
Dec 4, 2001
16
GB
Hi there,

I'm trying to list all the folders in my...folder!

I'm using the filesystemobject but I can only list out the files (probably cus it's the "file" system object), I've looked at the folder object on Microsoft's Developer Site but I don't quite understand they're examples.

Cheers for any help!
 
Try this:

<%
Dim strFolderName()

Dim fs
set fs = server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim i

ReDim strFolderName(1)
strFolderName(0) = &quot;c:\tmp&quot;
getfolder (strFolderName(0))
i = 0
Do While i < UBound(strFolderName)
Response.Write strFolderName(i) & &quot;<br>&quot; & vbcrlf
i = i + 1
Loop


Sub getfolder(strFolder)
Dim fs
set fs = server.CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set fld = fs.getfolder(strFolder)
For Each sfld In fld.SubFolders
ReDim Preserve strFolderName(UBound(strFolderName) + 1)
strFolderName(UBound(strFolderName)) = sfld.Path
getfolder (sfld.Path)
Next
End Sub
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top