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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.