Solved

fso & subFolders question (loop through folder and subfolders to display files)

Posted on 2008-06-18
3
1,175 Views
Last Modified: 2010-04-21
I am having a little trouble with the good ol fso fubfolder looping.  Here is what my folder structure looks like

Images
    accessories
           image 1
           image 2
    speakers
           image 1
           image 2
    car audio
           speakers
                   image 1
                   image 2
           head units
                   image 1
                   image 2

etc

I'm getting an error...

Microsoft VBScript runtime  error '800a01a8'
Object required: ''
/mc-high-res/Default.asp, line 37

What object am I goofing on?
Thanks
<%
dim fso,fileName,folderName,myMail,mailBody,subFolderName,imagesFolder,carSubFolder
set fso=Server.CreateObject("Scripting.FileSystemObject")
 
 
	'GRAB FOLDER
   imagesFolder = "E:\mcintosh-high-res-images\"
   carAudioFolder = imagesFolder & "CarAudio\"
 
    Set fso = CreateObject("Scripting.FileSystemObject") 
    Set allSubFolders = fso.GetFolder(imagesFolder) 	
	Set carSubFolders = fso.GetFolder(carAudioFolder)
	
	sub carAudiLoop
		for each subfolder in carSubFolders.subFolders
			carSubFolder = subfolder.Name
			Response.Write("<b>" & carSubFolder & "</b><ul>") 
			for each fileName in subfolder.files 
				response.write "<li>"& fileName.name & "</li>"
			next
			response.write "</ul>"
		next
	end sub
    
	
	
	
	for each subfolder in allSubFolders.subFolders 
	subFolderName = subfolder.Name
        Response.Write("<b>" & subfolderName & "</b><ul>") 
			
			if subFolderName = "CarAudio" then 			
				carAudiLoop
			end if
			
			for each fileName in subfolder.files 'LINE 37
				response.write "<li>"& fileName.name & "</li>"
			next
			response.write "</ul>"
    next 
    set fold = nothing 
    set fso = nothing 
 
%>

Open in new window

0
Comment
Question by:jweissdandm
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Badotz earned 125 total points
ID: 21816328
Try this:
                        if subFolderName = "CarAudio" then                      
                                carAudiLoop
                        else
                        
                                for each fileName in subfolder.files 'LINE 37
                                        response.write "<li>"& fileName.name & "</li>"
                                next
                                response.write "</ul>"
                        end if

Open in new window

0
 
LVL 2

Author Closing Comment

by:jweissdandm
ID: 31656935
yup, that did it. Thanks
0
 
LVL 29

Expert Comment

by:Badotz
ID: 21816633
No worries - glad to help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now