www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get Subfolders and filecounts

  1. #1
    Join Date
    May 2004
    Posts
    24

    Get Subfolders and filecounts

    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>

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Here ya go.
    Code:
    <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.

  3. #3
    Join Date
    Jan 2003
    Location
    USA
    Posts
    688
    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."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles