473,378 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Recursive directory using classic ASP

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 dk******@statestreet.com 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>

Jul 21 '05 #1
0 1922

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Foord | last post by:
I've been using the excellent XMLObject and have unfortunately come up against what *looks* to me like a bug - although it's very possible that the problem is mine !! I want to use XML object...
5
by: betterdie | last post by:
Dear guru I want to delete all file and folder recursivly under php code, can anyone give me commend for this. Thank very much
6
by: Talin | last post by:
I've been using generators to implement backtracking search for a while now. Unfortunately, my code is large and complex enough (doing unification on math expressions) that its hard to post a...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
1
by: Dane Carty | last post by:
Hi, Using a TreeView component to create a tree of the directories within my file system. I can't get my head around the logic of the recursion. Anyone with a bigger brain is welcome to...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
0
by: David | last post by:
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...
9
by: antonyliu2002 | last post by:
I have a C# class GeneralUtilities.cs , which many of my aspx.cs files will refer to. So, I've put it under the App_Code folder and compiled it to library using csc /target: library from the DOS...
2
by: sebastien.abeille | last post by:
Hello, I would like to create a minimalist file browser using pyGTK. Having read lot of tutorials, it seems to me that that in my case, the best solution is to have a gtk.TreeStore containing...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.