L
laura
I am writing some code for an intranet and I need to be able to list the
files in folders and subfolders and display them in the browser window as
with hyperlinks.
I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.
Here is the code which picks up file names without spaces and is called from
an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>
Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a> <br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub
Main()
%>
files in folders and subfolders and display them in the browser window as
with hyperlinks.
I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.
Here is the code which picks up file names without spaces and is called from
an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>
Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a> <br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub
Main()
%>