FSO Get Folder Names

I want to get all folder names with in a specific folder and put those names into an option box for the user to select from.  I am doing this already with files but I don't want to have to have worry about adding new folders manually to the previous option box.  

I know this can be done but how?  The option box I want to fill is called "cboDocFolders" and I want to see all of the folder names that are in the "AR_documentation" folder in the cboDocFolders.  For this many points I am looking for code.

This is what I have now:

<HTML>
<HEAD>
<Meta Http-EQUIV="expires" Content="0">
<meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">
<title></title>
</HEAD>
<BODY>


<%
'***********************************************************
'* Step 1: Display the type of item to select from
'***********************************************************
If Len(Request.Form("FormAction")) = 0 Then

%>

<form action="ar_documents.asp" method="post" name="frmDisplay">
  <input type="hidden" name="FormAction" value="Step2"><input type="hidden"
  name="txtDivision" ><input type="hidden" name="txtCurrentBid" ><input
  type="hidden" name="txtItemName" >

<TABLE border=0 cellPadding=1 cellSpacing=1 style="WIDTH: 526px; HEIGHT: 94px"
width="75%">
 
  <TR>
    <TD><STRONG><EM>Use the Box Below to Choose the Type of documentation you would like to look at:
    </EM></STRONG></TD></TR>
  <TR>
    <TD>

       
<SELECT name=cboDocFolders>
   <OPTION value="Systems" selected>Systems</OPTION>
   <OPTION value="Other">Other</OPTION>    
</SELECT>

     <script language=vbscript>
     
     Sub cboDocFolders_OnClick()
     'Save the Item name the user selects by clicking on the combo box
     frmDisplay.txtDivision.value =  _
     frmDisplay.cboDocFolders(frmDisplay.cboDocFolders.selectedIndex).value
     End Sub

     </script>

    </SELECT></TD></TR>
  <TR>
    <P><TD height="60"><INPUT name=btnSubmit type=submit value="  Next  "></TD></P></TR></TABLE>
<P></P>

<%
'*****************************************************************
'* Step 2: Get the Store the User would like to view
'*****************************************************************

ElseIf Request.Form("FormAction") = "Step2" Then

     Dim strFolder
     Set strFolder = Request.Form("cboDocFolders")
' File System Object
     Dim fso
          Set fso = Server.CreateObject("Scripting.FileSystemObject")

     ' "PDF" Folder
     Dim folder
          Set folder = fso.GetFolder("C:\Inetpub\wwwroot\aresearch\AR_documentation\" & strFolder & "")
          'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\Space_SQ\Stores\" & division & "")

%>

<FORM action="" method=post id=form1 name=form1>
<input type="hidden" name="txtDivisionName" value="<%=Request.Form("txtdivision")%>">
<%response.write "<STRONG><EM>Use the Box Below to Choose your Store: </EM></STRONG>"
response.write "<br><STRONG><EM>A new web page will open after you have selected your store.</EM></STRONG><br>"
%>
<SELECT id=select1 name=select1 onChange="javascript:window.open(this.value,'groovywindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=' + WinHeight + 'width=' + WinWidth + 'copyhistory=no')">

<script language="javascript">
if (window.screen) {
   var WinWidth = screen.availWidth;
   var WinHeight = screen.availHeight;
    WinWidth = WinWidth - 10;
    WinHeight = WinHeight - 25;
   }
</script>


<%If folder.Size > 0 Then %>


<% For Each file In folder.Files%>
<option VALUE= "AR_documentation/<%=strFolder%>/<%=file.Name%>"><% Response.write file.Name%></option>
          <%Next
     Else
          Response.Write "No pdf available"
     End If
%>


<%
Set folder = Nothing
Set fso = nothing


          %>
</SELECT>

</FORM>

<input type=Button value="&lt; Back" onclick="location.href='http://ho01wb01/aresearch/ar_documents.asp';">
<%
'<input type=Button value="&lt; Back" onclick="location.href='http://united-way/space_sq/ARSpace.asp';" id=Button1 name=Button1>
end if
%>


<P>&nbsp;
  <P></P>
  <P></P></P></TABLE></form>

</BODY>
</HTML>
flfmmqpAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fritz_the_blankCommented:
Okay, here is the first bit:

Dim objFSO, objSubfolder, objFolder,strPath
'set strPath to the path of your folder

set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder(strPath)
for each objSubfolderin objFolder.subfolders
  response.write("<option>" & objSubfolder.name & "</option>")
next
set objFolder=Nothing
set objFSO = Nothing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GaryCommented:
Place this code at the beginning somewhere then just write the variable selectbox where you need it displayed
<%
sPP = Server.MapPath("rootfoldername")

Set fso = CreateObject("Scripting.filesystemObject")
Set f = fso.Getfolder(sPP)

Set ff = f.Subfolders

selectbox="<select name=folders>"
For Each f1 in ff
selectbox=selectbox & "<option>" & f1.name
Next
selectbox=selectbox &"</select>"
response.write selectbox
%>
GaryCommented:
Fritz slow down I'm trying to catch you up. ;o) (And welcome :o)
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

fritz_the_blankCommented:
It is the first time that I have ever been on top for both lists! I am trying to savour the moment...


FtB
GaryCommented:
Oh yeah congrats on the half million mark :o)
fritz_the_blankCommented:
Why thank you sir!

FtB
flfmmqpAuthor Commented:
Can you give me an example of the strPath?

Thanks for the quick response by both of you.  I will try both to see which one works best for me.

Thanks again.
fritz_the_blankCommented:
What is the path to the folder that has all of your sub folders?

FtB
flfmmqpAuthor Commented:
I tried this but it did not work.

Set strPath = "C:\Inetpub\wwwroot\aresearch\AR_documentation"
flfmmqpAuthor Commented:
I'm getting this:

Microsoft VBScript runtime error '800a01a8'

Object required: '[string: "C:\Inetpub\wwwroot\a"]'

/aresearch/ar_documents.asp, line 61
GaryCommented:
Remove the Set - should just be
strPath = "C:\Inetpub\wwwroot\aresearch\AR_documentation"
fritz_the_blankCommented:
The path should look something like:

D:\My Documents\inProgress

BTW, there is a typo in my code:

for each objSubfolderin objFolder.subfolders


should be:

for each objSubfolder in objFolder.subfolders
fritz_the_blankCommented:
Here is the code that I am using in its entirety:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
      <title>Untitled</title>
</head>
<body>
<%
Dim objFSO, objSubfolder, objFolder,strPath
'set strPath to the path of your folder
strPath =server.MapPath("../inProgress")
set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder(strPath)
Response.write("<select name=strFolders>")
for each objSubfolder in objFolder.subfolders
  response.write("<option>" & objSubfolder.name & "</option>")
next
Response.write("</select>")
set objFolder=Nothing
set objFSO = Nothing
%>
</body>
</html>


FtB
fritz_the_blankCommented:
It also works if I do this instead:

strPath = "D:\My Documents\InProgress"

FtB
flfmmqpAuthor Commented:
I would like to thank both of you for your help.  I actually used bits and pieces of the information both of you gave me in the end.  So I would like to split up the points between you.  How do I do that?
fritz_the_blankCommented:
When you accept the answer, there should be an option to specify an assist, and then you can split the points that way.

So, the good news is that things work? Great!

FtB
flfmmqpAuthor Commented:
Yep they work now.  Which is awesome.  Thanks again.
fritz_the_blankCommented:
Glad to have helped,

FtB
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.