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

Frontpage VBSCRIPT question

Status
Not open for further replies.

AndyLord

Programmer
Jun 30, 2004
45
GB
[Rockband]

Can any hekp with this.

I am trying to creat a directory list, which will list all files containe in a specific directory, using VBScript. The problem is when I run the page nothing happens, it remains blank. The code is below:

***********************************************************

<%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit

Dim strDocsPath, strDocsPhysicalPath
Dim objFSO, objFolder, objFiles, objFile
Dim strName, strFile, strType, lngSize

strDocsPath = "\\George\UserHome\Common\Q & A"
strDocsPhysicalPath = Server.MapPath(strDocsPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strDocsPhysicalPath)
%>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 3</title>
</head>

<body>
<%
Set objFiles = objFolder.Files
For Each objFile in objFiles
strName = objFile.Name
strFile = LCase(strName)
strType = objFile.Type
strName = MakeTitle(strName)
lngSize = objFile.Size\1024
Response.Write "<li><a href=""" & strDocsPath & "\" & strFile & """>" & strName & "</a><br>"
Response.Write "<em>(" & lngSize & "KB" & strType & ")</em></li>" & vbCrLf
Next

Function MakeTitle(strTemp)
If InStrRev(strTemp,".") Then
strTemp = Left(strTemp,InStrRev(strTemp,".")-1)
End If
MakeTitle = strTemp
End Function
%>
</body>

</html>

********************************************************

Can anyone provide help with this.

What I am trying to achieve is to create a Windows style explorer for an Intranet, basically to view documents in a specific directory across a network. Any ideas?

Cheers in advance.
AndyLord
 
try this, I use it all the time. You will need to replace download2 with your directory name.

Code:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="The Spider's Parlor">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Customer Support Download Page</TITLE>
</HEAD>
<BODY>
<!--
This page created by Mark D. MacLachlan, The Spider's Parlor
-->

<table height=100%>
<tr>
	<td bgcolor="84A5C6" width=17% height=100%></td>
	<td valign=top>
		
		<%

		
		set directory=server.createobject("scripting.filesystemobject")
		set allfiles=directory.getfolder(server.mappath("/download2/"))
		
		' Lists all the files found in the directory
		For each directoryfile in allFiles.files 
				
			%>
			<a href=/download2/<%
			' Write out the name of the document
			response.write server.urlencode(directoryfile.name) %>><% response.write directoryfile.name %></a><br>
		<% 
				
		' End for next loop to list documents
		next 
				
		%> 
	</td>
	<td bgcolor="84A5C6" width=17% height=100%></td>
</tr>
</table>
</BODY>
</HTML>




I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top