I just came out with a quick and "dirty" method to perform simple
Directory Listing. I mention "dirty" because it is in VBScript and thus will work only on Microsoft Internet Explorer.
<html>
<head>
<title>Directory Listing: Copyright © Loh Hon Chun</title>
<script language="JavaScript">
<!--
window.defaultStatus = 'Directory Listing: Copyright © Loh Hon Chun';
//-->
</script>
<style>
a { color:#707070; text-decoration:none; }
a:hover { color:#000000; text-decoration:none; }
body {
font-size: 9pt;
color: #2F4F4F;
FONT-FAMILY: Arial;
margin-top: 20px;
margin-left: 50px;
}
h1 {
font-weight: bold;
font-size: 18pt;
font-family: Verdana;
color: #BC8F8F;
}
.header {
font-weight: bold;
font-size:10pt;
font-family: Verdana;
}
.displayMsg {
font-weight: bold;
font-size: 12pt;
font-family: Verdana;
}
.errorMsg {
color: #FF0000;
font-weight: bold;
font-size: 12pt;
font-family: Verdana;
}
</style>
</head>
<body>
<h1>Directory Listing</h1>
<script language="VBScript">
<!--
Function RecurseFolders(thisFolder)
Set objFolder = objFSO.GetFolder(thisFolder)
Document.Write "<span class=""header"">" & objFolder & "</span>"
For Each objFile in objFolder.Files
Document.Write " <a href=""" & objFolder.Path & "/" & objFile.Name & """>" & objFile.Name & "</a>"
Next
Document.Write ""
If Not objFolder.Subfolders.Count = 0 Then
For Each objSFolder in objFolder.SubFolders
RecurseFolders(objSFolder)
Next
End If
End Function
Dim objFSO, objFolder, objFile, objSFolder
Dim folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
folder = InputBox("Please enter directory")
If objFSO.FolderExists(folder) Then
Document.Write "<span class=""displayMsg"">Generating listing for <a href=""" & folder & """>" & folder & "</a></span>"
Call RecurseFolders(folder)
Else
Document.Write "<span class=""errorMsg"">Not such directory <u>" & folder & "</u></span>"
End If
'-->
</script>
</body>
</html>
Its really very easy to do the simple directory listing web application in VB Script. I like this method.
ReplyDelete