Hyperlink Sub Folders

L

laura

I am writing an intranet and want to be able to hyperlink to all files
within a specific folder AND it's subfolders. Whilst I can hyperlink to the
files in the specified folder AND I can also iterate through the subfolders
and list them, for some reason I cannot hyperlink to the sub folders. I am
writing this software at home using a computer that has IIS and Windows 98
and am accessing this as my server from another computer on my network.

My Home Page on the Server is http://maxitek (the name of my Windows98
Computer) and when I look at the value of the variable "PathSpec" - it
becomes C:\Inetpub\wwwroot\ which when I try to create links to the sub
folder it is probably here where the problem is. The files themselves link,
but not with their full subfolder names, i.e., for a file called
"C:\Inetpub\wwwroot\mytest\mytest2\mytest.txt" I am getting a link that just
looks like this
http://maxitek/mytest.txt It just misses out the path
/mystest/mytest2/mytest.txt and therefore the hyperlink does not work.

Help appreciated, Thanks
Laura TD

My code looks like this.

The Hyperlink that calls the ASP file:

<a href="dircompliance.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">Hyperlink to
all Files</a>

<%option explicit %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Filing System Scan</TITLE>
</HEAD>
<BODY>
<%
Dim Path, objFso
Path = request.querystring("PP")
Response.Write("<br><font size = '2' face='arial, helvetica,
sans-serif'><b>All Files Located in: " & Path & "</b><p>")
Set objFso = CreateObject("Scripting.FileSystemObject")
%>
<font size = 2 face="arial, helvetica, sans-serif">
<% Call ScanFolders(Path) %>
</font>
<%
Function ScanFolders(PathSpec)
Dim fs, f, Folder, fc, s, File, FileList, FolderInfo, FileName, Name,
sUU, sPP, Datecreated, LastModified, fullname
%>
<BLOCKQUOTE>
<%
Response.Write("<b>Full Path =" & PathSpec & "</b>")
Set FolderInfo = objFso.GetFolder(PathSpec)
Set FileList = FolderInfo.Files
%>
<table width=80% border=0 cellspacing=0 cellpadding=0>
<TR>
<TD><font size="2" face="arial"><b>File Name</b></font></td>
<TD><font size="2" face="arial"><b>Created</b></font></td>
<TD><font size="2" face="arial"><b>Last modified</b></font></td>
</TR>

<%
For Each File in FileList
Name = Cstr(File.Name)
FileName = UCase(Name)
fullname = pathspec&name
Datecreated = File.DateCreated
Lastmodified = File.DateLastModified
%>
<TR>
<%


Response.Write("<td><font size='2'
face='arial'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='" & Name &"'>" & Name
&"</a></font></td>")
Response.Write("<td><font size='2' face='arial'>" & Datecreated &
"</font></td>")
Response.Write("<td><font size='2' face='arial'>" & LastModified &
"</font></td>")
%>
</tr>
<%
Next
%>
</table>
</BLOCKQUOTE>
<%

Set f = objFso.GetFolder(PathSpec)
Set fc = f.SubFolders
For Each Folder in fc
%>
<BLOCKQUOTE>
<%
response.write("folder path " & f.path) ' just to show where I am
Call ScanFolders(PathSpec & Folder.Name & "\")

%>
</BLOCKQUOTE>
<%
Next
'Clean up!
Set FolderInfo = Nothing
Set FileList = Nothing
End Function
'Clean up!
Set objFso = Nothing
%>
</BODY>
</HTML>
 
M

McKirahan

laura said:
I am writing an intranet and want to be able to hyperlink to all files
within a specific folder AND it's subfolders. Whilst I can hyperlink to the
files in the specified folder AND I can also iterate through the subfolders
and list them, for some reason I cannot hyperlink to the sub folders. I am
writing this software at home using a computer that has IIS and Windows 98
and am accessing this as my server from another computer on my network.

My Home Page on the Server is http://maxitek (the name of my Windows98
Computer) and when I look at the value of the variable "PathSpec" - it
becomes C:\Inetpub\wwwroot\ which when I try to create links to the sub
folder it is probably here where the problem is. The files themselves link,
but not with their full subfolder names, i.e., for a file called
"C:\Inetpub\wwwroot\mytest\mytest2\mytest.txt" I am getting a link that just
looks like this
http://maxitek/mytest.txt It just misses out the path
/mystest/mytest2/mytest.txt and therefore the hyperlink does not work.

Help appreciated, Thanks
Laura TD

My code looks like this.

The Hyperlink that calls the ASP file:

<a href="dircompliance.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">Hyperlink

"Name" is a Reserved Word
and shouldn't be a variable name (to be safe):
Name = Cstr(File.Name)

Change from
&UU=//maxitek
to
&UU=http://maxitek/

You don't reference "UU"; as in:
Dim Where
Where = request.querystring("UU")

Then add under the "Function" name:
Dim LinkPath

Then add under the "For" loop
LinkPath = Mid(File.Path,Len(PathSpec))

Then change
<a href='" & Name &"'>
to
<a href='" & Where & LinkPath &"'>


I like to seperate logic from display (HTML);
so here's a variation of your code:

<%@ Language="VBScript" %>
<% Option Explicit
'*
Dim arrHTM()
ReDim Preserve arrHTM(9999)
Dim intHTM
intHTM = 0
Dim strHTM
Dim strQPP
strQPP = Request.QueryString("PP")
Dim strQUU
strQUU = Request.QueryString("UU")
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'*
AddLine("<br><b>All Files Located in: " & strQPP & "</b><p>")
Call ScanFolders(strQPP)
'*
Set objFSO = Nothing
ReDim Preserve arrHTM(intHTM)
strHTM = Join(arrHTM,vbCrLf)

Function ScanFolders(PathSpec)
AddLine("<BLOCKQUOTE>")
AddLine("<b>Full Path =" & PathSpec & "</b><br><br>")
Dim objGFO
Set objGFO = objFSO.GetFolder(PathSpec)
Dim objGFI
Set objGFI = objGFO.Files
'*
AddLine("<table border='0' cellspacing='0' cellpadding='0'
width='80%'>")
AddLine("<tr>")
AddLine(" <td><b>File Name</b><hr></td>")
AddLine(" <td><b>Created</b><hr></td>")
AddLine(" <td><b>Last modified</b><hr></td>")
AddLine("</tr>")
'*
Dim strFIL
For Each strFIL in objGFI
AddLine("<tr>")
AddLine(" <td><a href='" & strQUU & Mid(strFIL.Path,Len(strQPP))
&"'>" & strFIL.Name &"</a></td>")
AddLine(" <td>" & strFIL.DateCreated & "</td>")
AddLine(" <td>" & strFIL.DateLastModified & "</td>")
AddLine("</tr>")
Next
'*
AddLine("</table>")
AddLine("</BLOCKQUOTE>")
'*
Dim objGSF
Set objGSF = objGFO.SubFolders
Dim strFOL
For Each strFOL in objGSF
' Uncomment lines below to trace logic flow:
' Response.Write("<br>folder path " & strFOL.Path)
' Response.Write("<br>Call ScanFolders(" & PathSpec & strFOL.Name & "\") &
")"
AddLine("<BLOCKQUOTE>")
Call ScanFolders(PathSpec & strFOL.Name & "\")
AddLine("<BLOCKQUOTE>")
Next
'*
Set objGFO = Nothing
Set objGFI = Nothing
End Function

Sub AddLine(Text)
intHTM = intHTM + 1
arrHTM(intHTM) = Text
End Sub
%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Filing System Scan</TITLE>
<style type="text/css">
body { font-family:Arial; font-size:10pt }
td { font-family:Arial; font-size:10pt }
th { font-family:Arial; font-size:10pt; font-weight:bold }
</style>
</HEAD>
<BODY>
<%=strHTM%>
</BODY>
</HTML>

It still needs some work but you get the idea.
 
L

laura

Many thanks.

You will have gathered that I'm quite "green" at this. I've been assembling
the routine from bits of code gathered from different sources and just could
not get it to work. I see also that my programming structure has not been
very 'neat' either. I very much appreciate your help and it's very slick and
works exactly as I need. I have to go through it in detail line by line, to
understand what you've done and thanks for the lesson in separating the
logic from display.. that's going to take some getting used to also as I
have been completely mixing everything up.
I like to seperate logic from display (HTML);
so here's a variation of your code:

Thank you again.
Laura
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top