Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP/VBS List folders

Reply
Thread Tools

ASP/VBS List folders

 
 
Excel User
Guest
Posts: n/a
 
      09-22-2009
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!




















 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      09-22-2009
Excel User wrote:
> 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

--
HTH,
Bob Barrows


 
Reply With Quote
 
 
 
 
Excel User
Guest
Posts: n/a
 
      09-22-2009
Bob, thanks for the reply but changing this just repeats the folder name
several times i.e.

mainfolder
mainfolder
mainfolder
mainfolder

any ideas?

Thanks

"Bob Barrows" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Excel User wrote:
>> 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
>
> --
> HTH,
> Bob Barrows
>
>

 
Reply With Quote
 
Excel User
Guest
Posts: n/a
 
      09-22-2009
Bob,

Don't worry - I've found the error - all sorted.

Thanks again!

"Bob Barrows" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Excel User wrote:
>> 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
>
> --
> HTH,
> Bob Barrows
>
>

 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      09-22-2009
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.


Excel User wrote:
> Bob, thanks for the reply but changing this just repeats the folder
> name several times i.e.
>
> mainfolder
> mainfolder
> mainfolder
> mainfolder
>
> any ideas?
>
> Thanks
>
> "Bob Barrows" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> Excel User wrote:
>>> 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
>>
>> --
>> HTH,
>> Bob Barrows


--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
zipping files folders and sub folders w/ winzip or winrar Mike Computer Support 5 03-28-2008 09:10 PM
Desktop accesses laptop and reads folders but Laptop only accesses/opens Desktop but cannot read folders, access is denied onclejon Wireless Networking 3 11-01-2006 10:50 PM
NOTE: Storage on small folders, large folders, or one folder Pennywise@DerryMaine.Gov Computer Support 1 06-24-2006 09:09 AM
Error Using WMI to Get List of Shared Folders on the Server lecnac ASP .Net 1 04-21-2006 08:36 PM
Syncing POP folders with IMAP folders Rich Computer Support 1 02-12-2004 09:36 PM



Advertisments