|
Bnugent -> RE: Files listing in folder (1/19/2008 3:49:25)
|
rdouglass, this is great code, although i have a question....this seems to find the root/current directory of the asp page on which this code resides....what if i wanted to point to a share on my network or set a different directory? i tried changing this line like: ' get the current folder URL path strTemp = "//Labelclick05\c\Art Department\Operational\AutoLabel\LCC Customers\BMPS\Clients\ALTAVIEW" strPath = "//Labelclick05\c\Art Department\Operational\AutoLabel\LCC Customers\BMPS\Clients\ALTAVIEW" but it shows no results...when i copy paste in explorer the directory comes up so its valid...also tried with \\LABELCLICK05\c\Art..... How can you change the default root it searches to network folder? quote:
ORIGINAL: rdouglass I have a page script I use I've stripped down here (might be a few unused DIM's in there): <%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
On Error Resume Next
' declare variables
Dim objFSO, objFolder
Dim objCollection, objItem
Dim strPhysicalPath, strTitle, strServerName
Dim strPath, strTemp, foldName, foldTemp
Dim strName, strFile, strExt, strAttr, strDisplay
' don't cache the page
Response.AddHeader "Pragma", "No-Cache"
Response.CacheControl = "Private"
' get the current folder URL path
strTemp = Mid(Request.ServerVariables("URL"),2)
strPath = ""
Do While Instr(strTemp,"/")
foldTemp = Left(strTemp,Instr(strTemp,"/"))
strPath = strPath & Left(strTemp,Instr(strTemp,"/"))
strTemp = Mid(strTemp,Instr(strTemp,"/")+1)
Loop
foldName = Right(foldTemp,Instr(foldTemp,"/"))
foldName = Left(foldName,Len(foldName)-1)
strPath = "/" & strPath
' create the file system objects
strPhysicalPath = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
%>
<html>
<head>
<title>File List</title>
</head>
<body>
<table>
<%
''''''''''''''''''''''''''''''''''''''''
' output the file list
''''''''''''''''''''''''''''''''''''''''
Set objCollection = objFolder.Files
For Each objItem in objCollection
strName = objItem.Name
strFile = Server.HTMLEncode(strName)
%>
<tr>
<td align="left" colspan="2">
<%=strFile%></td>
</tr>
<% Next %>
</table> </div>
</body>
</html>
This works fine on an ASP enabled server. I don't know how it works off network shares but if the IUSR_machinename account has Read priv's, it should list every file in the directory this file is in. That help any?
|
|
|
|