473,584 Members | 2,840 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\wwwr oot\ 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\www root\mytest\myt est2\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="dircompli ance.asp?PP=C:\ Inetpub\wwwroot \&UU=//maxitek">Hyperl ink 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.queryst ring("PP")
Response.Write( "<br><font size = '2' face='arial, helvetica,
sans-serif'><b>All Files Located in: " & Path & "</b><p>")
Set objFso = CreateObject("S cripting.FileSy stemObject")
%>
<font size = 2 face="arial, helvetica, sans-serif">
<% Call ScanFolders(Pat h) %>
</font>
<%
Function ScanFolders(Pat hSpec)
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.GetFolde r(PathSpec)
Set FileList = FolderInfo.File s
%>
<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.DateCreate d
Lastmodified = File.DateLastMo dified
%>
<TR>
<%
Response.Write( "<td><font size='2'
face='arial'>&n bsp;&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.GetFolde r(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(Pat hSpec & 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 2325
"laura" <re*****@group. com> wrote in message
news:#k******** ******@TK2MSFTN GP10.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\wwwr oot\ 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\www root\mytest\myt est2\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="dircompli ance.asp?PP=C:\ Inetpub\wwwroot \&UU=//maxitek">Hyperl ink 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.queryst ring("UU")

Then add under the "Function" name:
Dim LinkPath

Then add under the "For" loop
LinkPath = Mid(File.Path,L en(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="VBScr ipt" %>
<% Option Explicit
'*
Dim arrHTM()
ReDim Preserve arrHTM(9999)
Dim intHTM
intHTM = 0
Dim strHTM
Dim strQPP
strQPP = Request.QuerySt ring("PP")
Dim strQUU
strQUU = Request.QuerySt ring("UU")
'*
Dim objFSO
Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
'*
AddLine("<br><b >All Files Located in: " & strQPP & "</b><p>")
Call ScanFolders(str QPP)
'*
Set objFSO = Nothing
ReDim Preserve arrHTM(intHTM)
strHTM = Join(arrHTM,vbC rLf)

Function ScanFolders(Pat hSpec)
AddLine("<BLOCK QUOTE>")
AddLine("<b>Ful l Path =" & PathSpec & "</b><br><br>")
Dim objGFO
Set objGFO = objFSO.GetFolde r(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>Create d</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.DateCrea ted & "</td>")
AddLine(" <td>" & strFIL.DateLast Modified & "</td>")
AddLine("</tr>")
Next
'*
AddLine("</table>")
AddLine("</BLOCKQUOTE>")
'*
Dim objGSF
Set objGSF = objGFO.SubFolde rs
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("<BLOCK QUOTE>")
Call ScanFolders(Pat hSpec & strFOL.Name & "\")
AddLine("<BLOCK QUOTE>")
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
2262
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 added some code for the click event, namely: Private Sub link_Click() Dim str As String If Not IsNull(Me.link) Then
1
2732
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 up the same way at runtime, but I haven't been able to get it to work. The field is set to be a hyperlink field. Then I try this: myString =...
4
2305
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 Acrobat, but I'd like to know how to do this for Excel, etc. Can anyone show me some code? I've looked on google and found only fragments,...
9
5596
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 server, WMP 10.0 . If I type the full path in an IE address field it plays the file in WMP When I test my Web page ( running the debugger in VS.)...
1
1340
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
1046
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
2721
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 my somewhat understanding of ASP I've been able to make the updates, but the menu (which is done in JavaScript) is not displaying at all. I checked...
20
2986
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 a control. I have 2 files "displayCompanyJobs.aspx" and "displayCompanyOverview.aspx" which are in both the folder "/jobseeker/" and "/employer/"....
3
1001
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 displaying a file name using this. i need to get the file name in codebehind (vb.net) to delete the particular file in gridview. I am not getting the values...
0
7897
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7829
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8190
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8331
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8200
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6590
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5705
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.