Recursive directory using classic ASP

G

Guest

Please help. I am able to display a folder structure and files but I can't
figure out how to add subfolders and maintain the same look. I am a little
embarrased but I thought someone out there could help me out with this one.
Please email me at (e-mail address removed) if you have a solution for me.

Thank you in advance,
Dave

<%@ Language=VBScript %>


<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>




<HTML>
<HEAD>
<TITLE>GCAS Phase 1</TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script language="javascript">
<!--
var Open = ""
var Closed = ""

function preload(){
if(document.images){
Open = new Image(16,13)
Closed = new Image(16,13)
Open.src = "images/open.gif"
Closed.src = "images/closed.gif"
}}


function showhide(what,what2){
if (what.style.display=='none'){
what.style.display='';
what2.src=Open.src
}
else{
what.style.display='none'
what2.src=Closed.src
}
}

-->
</script>
<!--<base target="_blank">-->
</HEAD>
<body onload="preload()" vlink="#0000FF" alink="#0000FF" leftmargin=30
topmargin=30>

<table cellSpacing="0" cellPadding="0" width="760" border="0">
<tr valign=bottom>
<td bgColor="#acc9e8">
<p align=left><font color="#000080" face="verdana" size=3><B>Project:
GCAS Phase 1</B>
</td>
</tr>
</table>
<BR>
<table cellSpacing="0" cellPadding="0" width="760" border="0">
<tr valign=bottom>
<td>
<!--<div align="center">-->
<p align=center><font color=MidnightBlue face="verdana"
size=3><B>Deployment Binder</B>
</td>
</tr>
</table>
<p>
<%
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

' A recordset object variable and some selected constants from adovbs.inc.
' I use these for the sorting code.
Dim rstFiles
Const adVarChar = 200
Const adInteger = 3
Const adDate = 7

strPath = "C:\Inetpub\ftproot\gcasdocs\"
' Create our FSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Get a handle on folder
Set objFolder = objFSO.GetFolder(strPath)
Set rstFolders = server.CreateObject("ADODB.Recordset")
rstFolders.fields.append "fname", adVarChar, 255
rstFolders.fields.append "fdate", adDate
rstFolders.open

i = 1
For Each objItem In objFolder.SubFolders
' Deal with the VTI's that give us 404's
If InStr(1, objItem, "_vti", 1) = 0 Then
rstFolders.addnew
rstFolders.fields("fname").Value = objItem.Name
'Debug.Print rstFolders.fields("fname").Value
'rstFolders.fields("fdate").Value = objItem.DateLastModified
rstFolders.fields("fdate").Value = objItem.DateCreated
'Debug.Print rstFolders.fields("fdate").Value
End If
Next

If Not rstFolders.BOF And Not rstFolders.EOF Then
rstFolders.Sort = "fdate ASC"
'rstFolders.MoveFirst
Dim FSO, strFPath, oFolder, oFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Do While Not rstFolders.EOF


Set rstFiles = server.CreateObject("ADODB.Recordset")
rstFiles.fields.append "name", adVarChar, 255
rstFiles.fields.append "size", adInteger
rstFiles.fields.append "date", adDate
rstFiles.fields.append "type", adVarChar, 255
rstFiles.open


%>

<font face="Verdana" size="2">
<span id="menu<%=i%>" onClick="showhide(menu<%=i%>outline,menu<%=i%>sign)"
style="cursor:hand; font-Family:Verdana; text-decoration:underline;
font-weight:bold"><font style="text-decoration:none">
<img id="menu<%=i%>sign" src="images/closed.gif" valign="bottom"
width="16" height="13"> </font></span>
<span style="cursor: hand; font-family: Verdana; text-decoration:
underline; font-weight: bold"
id="menu1" onClick="showhide(menu<%=i%>outline,menu<%=i%>sign)"><%=
rstFolders.fields("fname").Value %></span><br>
<%
strFPath = "C:\Inetpub\ftproot\gcasdocs\" &
rstFolders.fields("fname").Value & "\"
Set oFolder = FSO.GetFolder(strFPath)
For Each oFile In oFolder.Files
'If objItem.Type = "Microsoft Excel Worksheet" or
objItem.Type = "Microsoft Word Document" Then
rstFiles.addnew
rstFiles.fields("name").Value = oFile.Name
rstFiles.fields("size").Value = oFile.Size
rstFiles.fields("date").Value = oFile.DateCreated
rstFiles.fields("type").Value = oFile.Type
'End IF
Next 'oFile

If Not rstFiles.BOF And Not rstFiles.EOF Then
rstFiles.Sort = "date DESC"

%>
<span id="menu<%=i%>outline" style="display:'none'">
<%
Do While Not rstFiles.EOF
'Response.Write objItem
%>
&nbsp;
<a href="<%="//10.1.56.84/ftproot/gcasdocs/" &
rstFolders.Fields("fname").Value & "/" & rstFiles.Fields("name").Value
%>"><%= rstFiles.Fields("name").Value %></a><br>
<%
rstFiles.MoveNext
Loop
rstFiles.Close
Set rstFiles = Nothing

%>
</span>
<%
Else
%>
<span id="menu<%=i%>outline" style="display:'none'"> </span>
<%
End If
i = i + 1
rstFolders.MoveNext
'Response.Write("<BR>")
Loop%>
<%End If

'objItem
' Close Recordset object
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
<BR>
<table cellSpacing="0" cellPadding="0" width="760" border="0">
<tr>
<td bgColor="#acc9e8">
<div align="center">
<p style="margin-top: 0; margin-bottom: 0" align="right">
<font face="Wingdings" color="#008000">
<a href="gcasupload.asp" style="text-decoration: none">
<font color="#FF0000">Ã</font></a></font><font color="#000080"
face="Arial"><a href="gcasupload.asp" style="text-decoration: none">
<font size="2">UPLOAD NEW FILE</font> </a>
</font>
<font face="Wingdings" color="#008000">
<a href="aixupload.asp" style="text-decoration: none">
<font color="#FF0000">Ã</font></a></font></div>
</td>
</tr>
</table>
</BODY>
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>


</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top