473,386 Members | 1,795 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,386 software developers and data experts.

Hyperlink Sub Folders

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>


Jul 22 '05 #1
2 2314
"laura" <re*****@group.com> wrote in message
news:#k**************@TK2MSFTNGP10.phx.gbl...
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>


"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.

Jul 22 '05 #2
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

Jul 22 '05 #3

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

Similar topics

1
by: Krechting | last post by:
Hi All, I have two hyperlinkfields in my database. Both fields have to point to different folders. One is called "IN" and the other "OUT". Access can have only one hperlinkbase. That's why I...
1
by: jodyblau | last post by:
I have noticed that if you right click on a hyperlink field and edit the hyperlink, you can set it to be an email address and open up Outlook when it is clicked. I have been trying to set this...
4
by: mrmagoo | last post by:
I want to loop through a directory and list all files in hyperlinks. Then when you click on a hyperlink, it opens the file in whatever application it needs. For now I need to do this with Adobe...
9
by: Morris Neuman | last post by:
Im working with VS 2005 and trying to use a Hyperlink field in a datagrid to play a wave file that is not located in the website folders but is in a plain folder on the same machine, windows 2003...
1
by: bbawa1 | last post by:
I have a table with two columns AppName AppLocation TestApp1 folder1 TestApp2 folder2 TestApp3 folder3 TestApp4 folder4 TestApp5 folder5
0
by: bbawa1 | last post by:
I have a table with two columns AppName AppLocation TestApp1 folder1 TestApp2 folder2 TestApp3 folder3 TestApp4 folder4 TestApp5 folder5
6
by: fperri | last post by:
Hi, I'm very new to ASP, and I have been thrown into updating a website that was already written in ASP and pushing it to the web for the first time. So far, with my old knowledge of html and...
20
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
3
by: srinme | last post by:
<asp:HyperLink ID="hlkFilename" runat="server" NavigateUrl='<%#PopulatePath(Eval("FullName").ToString(),Eval("Name").ToString()) %>' target="_blank" ><%#Eval("Name")%></asp:HyperLink> I am...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.