navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Files listing in folder

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Files listing in folder
Page: [1]
 
dzirkelb1

 

Posts: 1300
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
Files listing in folder - 1/15/2008 15:02:45   
I have the following page I am trying to move over to sharepoint server. I modified it to look like this:

<%@ Language=VBScript %>
<html>
<body>
<table>
hello
<%
Dim fso, folder, files

Set fso = Server.CreateObject("Scripting.FileSystemObject")

Set folder = fso.GetFolder("Z:\Intranet\Images\2002HolidayParty")

For Each files in folder.Files
	%>
	<tr>
		<td><a href="http://cdrsharepoint/everything/2002HolidayParty/<%=files.Name%>" target="_blank"><%=files.Name%></a></td>
	</tr>
	<%
Next
%>
</table>
</body>
</html>


The link in the loop should be correct; however, nothing is listed at all. Is this because the Z drive is a network drive? The images folder has the rights of everyone to full permisions.

I tried changing the drive to be local to the sharepoint server (c:\2002 was my test) and it didn't work that way either. Any ideas?
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Files listing in folder - 1/16/2008 13:21:39   
Are you saying a known folder on the server does not work either?
No error is created?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1300
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: Files listing in folder - 1/16/2008 13:23:10   
Correct, just a blank page is displayed.

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Files listing in folder - 1/16/2008 13:36:25   
Any code if you view > source ?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to dzirkelb1)
rdouglass

 

Posts: 9228
From: Biddeford, ME USA
Status: offline

 
RE: Files listing in folder - 1/16/2008 13:40:06   
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?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to dzirkelb1)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Files listing in folder - 1/16/2008 13:49:12   
I tested the basic code above and it does work on my asp server - so I dont think its the code, more what the server supports

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to rdouglass)
dzirkelb1

 

Posts: 1300
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: Files listing in folder - 1/16/2008 14:35:21   
This is what is shown on view source:

<%@ Language=VBScript %>
<html>
<body>
<table>
hello
<%
Dim fso, folder, files

Set fso = Server.CreateObject("Scripting.FileSystemObject")

Set folder = fso.GetFolder("Z:\Intranet\images\2002HolidayParty")

For Each files in folder.Files
	%>
	<tr>
		<td><a href="http://cdrsharepoint/everything/2002HolidayParty/<%=files.Name%>" target="_blank"><%=files.Name%></a></td>
	</tr>
	<%
Next
%>
</table>
</body>
</html>


the hello does show up.

(in reply to dzirkelb1)
rdouglass

 

Posts: 9228
From: Biddeford, ME USA
Status: offline

 
RE: Files listing in folder - 1/16/2008 15:02:32   
Hate to ask but is this on an .ASP page and not an .HTM (or something else) page? You should not be seeing anything between the <% and the %> in the view source.

From the browser of course.

EDIT: And ASP is enabled on the web? If you're using the latest IIS it's not enabled by default.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1300
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: Files listing in folder - 1/16/2008 15:10:36   
It's a sharepoint server, so I am assuming everything is installed on IIS. I can run other .asp pages on the server and they run correctly.

It's not a big deal as I have numerous workarounds I can do, was just seeing if anything popped out in front of you guys.

The page is .asp also, and I'm not sure why it shows the asp code on view source.

(in reply to rdouglass)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Files listing in folder - 1/16/2008 15:59:57   

http://classicasp.aspfaq.com/general/why-won-t-my-asp-pages-work-in-iis-6-0.html

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1300
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: Files listing in folder - 1/16/2008 16:03:38   
That's a good reference, but I get no errors on anything, and my other .asp pages run fine.

(in reply to Spooky)
Bnugent

 

Posts: 257
From: Tampa Florida Tampa, FL USA
Status: offline

 
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?



_____________________________

Brian---

(in reply to rdouglass)
rdouglass

 

Posts: 9228
From: Biddeford, ME USA
Status: offline

 
RE: Files listing in folder - 1/19/2008 10:50:29   
quote:

How can you change the default root it searches to network folder?


Hi Brian,

The FSO works relative to the server and AFAIK the UNC doesn't work but needs to be a mapped path from the server ie. "Z:\SharedData\" and it needs to be a Virtual Directory in IIS. (Or at least that's the only way I know of).

So if that's the case and the shared volume is mapped as in the path above, you'd change this line to:

Set objFolder = objFSO.GetFolder("Z:\SharedData")

Eariler in the script I use the MapPath command and grab the location of the page that's running this script. The bold above maps the path specifically.

That help any?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Bnugent)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Files listing in folder
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts