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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View directory contents dynamically

Status
Not open for further replies.

Davetoo

IS-IT--Management
Oct 30, 2002
4,498
0
0
US
I'm trying to setup an Intranet site that our users can go to and view information that is located on our file servers.

I know I can display an Explorer style window using the file:\\\ command (or something like that), but I don't want to do that. What I want to do is display the contents of a folder, including any sub-folders, so that a user can select the file to view (usually a PDF or a Word Document), or select a sub-folder and have that then display the contents of that folder without using the Windows Explorer style view.

The problem I've run into is when there is a sub-folder, the user can't select the sub-folder to view it.

Can anyone point me in the right direction? Not sure if HTML can do this.

TIA

I'm Certifiable, not certified.
It just means my answers are from experience, not a book.
 
Check with the web admin. Generally if directory browsing is enabled (Windows anyway) then if you link to a directory it will show the folder list including subfolders for users to browse (can't edit)

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Thanks, but that's what I don't want. Instead, I want it to read the contents of the directory and display it with automatic links to the files.

I'm trying to make it not look like a Windows Explorer window.

I'm Certifiable, not certified.
It just means my answers are from experience, not a book.
 
An excerpt from one asp page we use is below. It reads the files in a folder into an array and then builds them into a table of links. You could extend it to sub directories with a bit of work.

<% Response.Buffer=True%>
<%Response.Expires=0%>
<%
' By: Blaine Wheeler
' October 8, 2002
' DCS SEMS Operations
' Purpose: Display Any and all technical docs from the \techdocs folder
'
' Modification History:
' 10/15/02 added file mod date to display
' 10/30/02 converted to a record set and added sorting ability.

' *******************************
' Global Variables and Objects
' *******************************
Set oFso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim rs
' Folder, must be through a mapped drive on IIS server
CONST strFolder = &quot;i:\techdocs&quot;

' Send the string folder path to the FindIt function and assign the returned data to the object rs
Set rs = FindIt (strFolder)

' Sort the returned data
If Request.QueryString(&quot;sortBy&quot;) <> &quot;&quot; Then
rs.Sort = Request.QueryString(&quot;sortBy&quot;)
Else
rs.Sort = Request.QueryString(&quot;Base&quot;)
End if


'***********************************************
Function Findit (strFolder)
' Loop through the files building the record set
Dim fil, filenames, rs, oFolder
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Set oFolder = oFso.GetFolder(strFolder)
Set filenames = oFolder.Files
Const adDate = 7
Const adVarChar = 200

' Make the RS
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Fields.Append &quot;FileName&quot; , adVarChar , 200
rs.Fields.Append &quot;Base&quot; , adVarChar, 200
rs.Fields.Append &quot;Created&quot; , adDate
rs.Fields.Append &quot;LastMod&quot; , adDate
rs.Open

For each fil in filenames
rs.AddNew
rs(&quot;FileName&quot;) = oFso.GetBaseName (fil) & &quot;.&quot; & oFso.GetExtensionName(fil)
rs(&quot;Base&quot;) = oFso.GetBaseName (fil)
rs(&quot;Created&quot;) = FormatDateTime (fil.DateCreated , 2)
rs(&quot;LastMod&quot;) = FormatDateTime (fil.DateLastModified , 2)
rs.Update
Next
rs.MoveFirst
Set FindIt = rs
End Function

Sub Die
If IsObject (oFso) Then Set oFso = Nothing
End Sub

' *******************************
' Subs and Functions
' *******************************

%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
' We have the page title and style sheet path here
</HEAD>
<BODY>

Revised: October 8, 2002
<br>
<h4>This page displays Hardware and maintenance bulletins as well as instructions from SEMS Operations.</h4>

<table>
<tr>
<td><a href=&quot;TechDocs.asp?sortBy=Base&quot; title=&quot;Sort by document name&quot;><strong>Name</strong></a></td>
<td><a href=&quot;TechDocs.asp?sortBy=Created DESC&quot; title=&quot;Sort by date created&quot;><strong>Created</strong></a></td>
<td><a href=&quot;TechDocs.asp?sortBy=LastMod DESC&quot; title=&quot;Sort by last modified date&quot;><strong>Last Modified</strong></a></td>
</tr>
<%Do While Not rs.EOF%>
<tr>
<td class=&quot;tite&quot;><a href=&quot;/ target=&quot;Bob&quot;><%=rs(&quot;Base&quot;)%></a></td>
<td class=&quot;tite&quot;><%=rs(&quot;Created&quot;)%></td>
<td class=&quot;tite&quot;><%=rs(&quot;LastMod&quot;)%></td>
</tr>
<%rs.MoveNext%>
<%Loop%>
</table>

</body>
</html>
<%
Die
Response.End
%>
 
Blain,

Thanks for that, but I have no experience in ASP. I tried to just run the code but, of course, just got the HTML at the bottom, nothing filled in. It looks like exactly what I want it to do, but unfortunately I just don't know how to make it work.

I'm Certifiable, not certified.
It just means my answers are from experience, not a book.
 
I solved my problem by simply utilizing Virtual Directorys in IIS. It was exactly what I wanted.

I'm Certifiable, not certified.
It just means my answers are from experience, not a book.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top