Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Feb 13, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Creating an HTML Directory in ASP

Although most Web servers give you the option of allowing users to view the list of files in a Web site directory, you may not want to show some types of files. Also, you may want to present the list of files in attractive table. The following code, written for Internet Information Server with Active Server Pages (ASP), displays all of the GIF files in the directory C:\inetpub\wwwroot\work. It also shows the size of the file, the type, the date that it was last accessed, and when it was last modified. Update the variables called thepath and thefile to reflect your Web's path and the type of file that you want to display.
<%@ Language=VBScript %>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<!--Ken Cox kenc@corinet.com January 1999-->
<TABLE background="" bgColor=#99cccc 
border=1 borderColor=#669999 
borderColorDark=#ffffff borderColorLight=#000000 
cellPadding=4 cellSpacing=1>
dim thepath, thefile

Set fs = CreateObject("Scripting.FileSystemObject")
Call ShowFolderList(thepath)
Set fs=Nothing

Sub ShowFolderList(folderspec)
On error resume next
Set f = fs.GetFolder(folderspec)
Set fc = f.Files 
For Each f1 in fc
If instr(1,ucase(f1.name),ucase(thefile)) Then
Response.Write "<tr>"
Response.Write "<td><a href='" & f1.name & "'>" & f1.name & "</a></td>"
Response.Write "<td>" & f1.size & "</td>"
Response.Write "<td>" & f1.type & "</td>"
Response.Write "<td>" & f1.DateLastAccessed & "</td>"
Response.Write "<td>" & f1.DateLastModified & "</td>"
Response.Write "</tr>" 
End If
End Sub
Ken Cox
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date