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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Folders

Status
Not open for further replies.

PenguinHead

Programmer
Jan 5, 2007
18
US
I want to list within a page the folders and files that exist within a specific location. Currently I am able to list the files, but can't seem to get the folders to be listed as well. Any tips?
 

Response.Write objFolder.Name
Where objFolder is the the object variable assigned by FSO. For example:
Code:
<%
Dim objFSO
Dim objFolder
Dim objSubFolder
Dim objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Get Current Folder
Set objFolder = objFSO.GetFolder(Server.MapPath("."))
Response.Write "Current Folder: " & objFolder.Name & "<br/>"
For Each objSubFolder In objFolder.SubFolders
    Response.Write "    SubFolders: " & objSubFolder.Name & "<br/>"
Next
This was written on the fly so errors are possible (read: likely) but it's the right direction. Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top