ASP/VBS List folders

E

Excel User

Hi,

I have the following script which lists all the folder names from
'mainfolder'

ListFolderContents(Server.MapPath("/mainfolder"))

sub ListFolderContents(path)

dim fs, folder

set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)

Response.Write(folder.Name & "<br>")

for each item in folder.SubFolders
ListFolderContents(item.Path)
next

end sub

but I would like to just list the first set of sub folders not the folders
within these sub folders i.e. if I had the following directory structure

mainfolder
- folder 1
- sub folder 1
- folder 2
- sub folder 2a
- sub folder 2b
- folder 3


so I would only like to list the folder names with 'mainfolder' but not
their sub-folders

i.e.
folder 1
folder 2
folder 3

Thanks for any help!
 
B

Bob Barrows

Excel said:
Hi,

I have the following script which lists all the folder names from
'mainfolder'

ListFolderContents(Server.MapPath("/mainfolder"))

sub ListFolderContents(path)

dim fs, folder

set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)

Response.Write(folder.Name & "<br>")

for each item in folder.SubFolders
Response.Write(folder.Name & "<br>")
next

end sub

but I would like to just list the first set of sub folders not the
folders within these sub folders i.e. if I had the following
directory structure

Replace the recursive call to the sub with a statement to write the
subfolder name to Response. See above
 
E

Excel User

Bob, thanks for the reply but changing this just repeats the folder name
several times i.e.

mainfolder
mainfolder
mainfolder
mainfolder

any ideas?

Thanks
 
B

Bob Barrows

Well, I was somewhat hoping that you would pick up on what needed to be done
.... and I now see that you did. Well done.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top