Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 28th, 2004, 04:17 AM
Registered User
Join Date: Dec 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch. 10 Directory listing

Hello everyone. I took the code for directory listing in chapter 10

I have this code
<TITLE>AM Signalen</TITLE>

Dim strPathInfo, strPhysicalPath
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Dim objFSO, objFile, objFileItem, objFolder, objFolderContents
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files

<TABLE cellpadding=5>
<TR align=center>
<TH align=left>File Name</TH>
<TH>File Size</TH>
<TH>Last Modified</TH>

For Each objFileItem in objFolderContents

     <TD align=left>
     <A HREF="<%= objFileItem.Name %>">
     <%= objFileItem.Name %>
     <TD align=right>
     <%= objFileItem.type %>
     <TD align=right>
     <%= objFileItem.size %>
     <TD align=right>
     <%= objFileItem.DateLastModified %>



But it shows the files in the directory this file resides. I included 3 files (upper config.asp & inc_header, down inc_footer.asp) to give this page my own look and feel. Therefore i need the code to place in my /forum directory. This code shown above gives me a directory listing of that directory. How can ik rewrite my code so the codefile is in the /forum directory but i can point to another directory to show files, for example http://www.mixz.local/amsignals

Thanx in advance
  #2 (permalink)  
Old March 3rd, 2005, 07:39 AM
Registered User
Join Date: Mar 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts


I'm a beginner, here, too.

However, I have a similar problem to yours, and have solved part of it.

In order to make the script list the contents of a different directory than the one it lives in, you need to change the value of the strPhysicalPath variable...

I just directly set mine to the directory concerned like this:

strPhysicalPath = Server.MapPath("../../test/dummy.asp")

and put a dummy ASP file into the relevant directory.

Running the script from it's own resting place (<root_directory>/scripts/wroxbook/) it correctly displays the content of the directory: <root_directory>/test/

What I can't figure out is how to make the displayed links fetch the right pages (from the <root_directory>/test/ directory), rather than returning a 404 error (because it seems to be trying to fetch them from the <root_directory>/scripts/wroxbook/ directory)...

Any suggestions welcome.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing 8-10 and Listing 8-16. Asp.Net BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 February 6th, 2008 01:11 PM
Listing of Directory Content ram_dwivedi Javascript 3 December 9th, 2005 05:13 AM
FSO directory listing spinout Classic ASP Components 4 November 7th, 2004 03:18 AM
Directory Listing Bleetz Pro JSP 1 September 20th, 2003 06:25 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.