Question : fso loop through folders and files

I need to do a simple fso loop through a root level and multiple sub levels and display the contents of each sub folder

Images
    accessories
           image 1
           image 2
    speakers
           image 1
           image 2
   
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
I have the code for each part but putting them together is confusing...

'SHOW FOLDERS
dim fs,fo,xFolder
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("D:\corporate\Denon\2010images\images\")

for each xFolder in fo.SubFolders
  Response.write(xFolder.Name & "<br />")
next

set fo=nothing
set fs=nothing



'SHOW FILES IN A FOLDER
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("c:\test\")

for each x in fo.files
  'Print the name of all files in the test folder
  Response.write(x.Name & "<br />")
next

set fo=nothing
set fs=nothing

Answer : fso loop through folders and files

This is tested and works, just change the folder path as necessary;
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
<head>
	<title>Untitled</title>
<Style type="text/css">
.title {
	color: #00008b;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	text-decoration: underline;
	height: 2px;
}
.file {
	color: #6869ff;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	height: 1px;
}
</style>
</head>

<body>
<%
dim fs,fo,xFolder, theFolder

thePath = Server.MapPath("/templates")
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(thePath)

for each xFolder in fo.SubFolders
	theFolder = xFolder.Name
	Response.write("<div class=title>" &theFolder & "</div><br />")
	set fo=fs.GetFolder(thePath & "/" & theFolder)

	for each x in fo.files
		'Print the name of all files in the test folder
		Response.write "<div class=file>&nbsp;&nbsp&nbsp;&nbsp;" & x.Name & "</div><br />"
	next
next

set fo=nothing
set fs=nothing
%>
Random Solutions  
 
programming4us programming4us