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

VBScript List Directory Contents problem

Status
Not open for further replies.

AndyLord

Programmer
Jun 30, 2004
45
0
0
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
 
I don't see how [tt]strDocsPhysicalPath[/tt] is returning anything. I'm seeing a leading double backslash in yoir code that is not UNC to a netowork share:

Code:
strDocsPath = "\\George\UserHome\Common\Q & A"

This code should return [tt]0[/tt]:

Code:
strDocsPath = "\\George\UserHome\Common\Q & A"
strDocsPhysicalPath = Server.MapPath(strDocsPath)
Call Response.Write(Len(strDocsPhysicalPath ))
Response.End


Right?

Bryan Wilhite
Songhay System
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top