Click to See Complete Forum and Search --> : Get Subfolders and filecounts


MaxHewitt
05-30-2004, 09:55 AM
I'm trying to create an ASP page that will create a dropdown menu of the names of subdirectories on the server.

Then after the user selects the dropdown menu, retrieve the number of files (filecount) in that subdirectory. Currently I have all this information scripted into JavaScript at http://www.hewittsinc.com/max/java/slideshows.htm, but I'd like to be able to change this so that all I have to do is upload the subdirectories and files.

Can anyone help?

Here's what I have so far:

<form name="vbgetfolder" method="post" action="">
<select name="fld" onChange="submit()">
<option value="selected">Select a folder --&gt;</option>
<%
const subdir = "\images\"
dim objFSO
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
for each fldr in Server.MapPath(subdir)
'what goes here?
next fldr
%>
</select>
</form>

buntine
05-30-2004, 09:37 PM
Here ya go.

<form name="vbgetfolder" method="post" action="">
<select name="fld" onChange="submit()">
<option value="selected">Select a folder --&gt;</option>
<%
const subdir = "\images\"
dim objFSO
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
for each fldr in Server.MapPath(subdir)
Response.Write ("<option>" & fldr & "</option>")
next fldr
%>
</select>
</form>

Regards,
Andrew Buntine.

Bullschmidt
06-18-2004, 03:16 AM
And here's a related resource:

Using the FileSystemObject for Web Site Maintenance, Part 2 - 9/14/1999
http://www.4guysfromrolla.com/webtech/091499-1.shtml
"Since there are an undetermined number of subdirectories in a given directory, and since each subdirectory may contain its own set of subdirectories, which in turn may contain their own set of subdirectories, and so on and so on, it is imperative that we use recursion."