Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a simple Directory Page?

Status
Not open for further replies.

Flapman

Technical User
Jul 6, 2001
18
US
I would like to learn how to make a simple directory page that will automatically list all the files in that folder I created.

Flapman
 
there is a directory listing asp page at
I have stripped this down to have a Directory list as a menu and a drop down for document browsing.
 
Directory Listing
<%' Now to the Runtime code:
Dim strPath 'Path of directory to show
Dim objFSO 'FileSystemObject variable
Dim objFolder 'Folder variable
Dim objItem 'Variable used to loop through the contents of the folder

' You could just as easily read this from some sort of input, but I don't
' need you guys and gals roaming around our server so I've hard coded it to
' a directory I set up to illustrate the sample.
' NOTE: As currently implemented, this needs to end with the /
strPath = &quot;./&quot;

' Create our FSO
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)

' Get a handle on our folder
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))


%>


<BR>

<TABLE BORDER=&quot;5&quot; BORDERCOLOR=&quot;green&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;2&quot;>
<TR BGCOLOR=&quot;#006600&quot;>
<TD></TD>

</TR>
<%

' First I deal with any subdirectories. I just display them and when you
' click you go to them via plain HTTP.
For Each objItem In objFolder.SubFolders
' Deal with the stupid VTI's that keep giving our visitors 404's
If InStr(1, objItem, &quot;_vti&quot;, 1) = 0 Then
%>
<TR BGCOLOR=&quot;#CCFFCC&quot;>
<TD ALIGN=&quot;left&quot; ><A HREF=&quot;<%= strPath & objItem.Name %>&quot;><%= objItem.Name %></A></TD>

</TR>
<%
End If
Next 'objItem



' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing


%>
</TABLE>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top