Print Page | Close Window

Directory Listing

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5581
Printed Date: 03 April 2026 at 12:25am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Directory Listing
Posted By: webpromo
Subject: Directory Listing
Date Posted: 07 September 2003 at 7:30am

Hello,

  I have a directory with several sub directories.  I would like to list all the files in the directory and subdirectories with the full path of each file.

Is there any way to do this...would be ideal to have it done in ASP or PHP...but really dont have to be.

Any ideas?

Thanks in advance!
Chris K.




Replies:
Posted By: MadDog
Date Posted: 07 September 2003 at 10:39am
Post in the right forum!

-------------
http://www.iportalx.net" rel="nofollow">


Posted By: webpromo
Date Posted: 07 September 2003 at 10:55am

Ya...I noticed that after....but couldn't delete it.

Sorry.



Posted By: Bborg
Date Posted: 07 September 2003 at 3:05pm

Hi!

try this code:

<!----------------------------default.asp---------------- --------->

<div align="center">
<center>
<table width="500" cellpadding="3" bgcolor="#000000" cellspacing="1">
<tr>
<td width="100%" bgcolor="#C0C0C0">
FileName
</td>
</tr>
<%
'set the folder of system and the starting path of the folder to list
'if you keep the links to files on list, then this folder must be the
'folder where you have this file; otherwise the links to the files on list will not work
Path = "C:\Inetpub\listfolders"
'select a subfolder to list and specify the rest of patch of teh selected folder
'if request the list of folder1, then
If Request.Querystring("list") = "folder1" Then
'the rest of path to this folder is
ListFolder = "mysubfolders\folder1"
'if request the list of folder2, then
ElseIf Request.Querystring("list") = "folder2" Then
'the rest of path to this folder is
ListFolder = "mysubfolders\folder2"
'if request the list of folder3, then
ElseIf Request.Querystring("list") = "folder3" Then
'the rest of path to this folder is
ListFolder = "mysubfolders\folder3"
'if not request a folder, then list the links to your files on your subfolders
ElseIf Request.Querystring("list") = "" Then
%>
<tr>
<td width="100%" bgcolor="#FFFFFF">
<a href="default.asp?list=folder1">List the files of folder 1</a>
<br>
<a href="default.asp?list=folder2">List the files of folder 2</a>
<br>
<a href="default.asp?list=folder3">List the files of folder 3</a>
</td>
</tr>
<%
'end of select subfolders
End If
'create the object to list files of your subfolders
Set fs = Server.CreateObject("Scripting.FileSystemObject")
'we already have the beginning of system folder path and the rest of path
'(the subfolder to list), then, lets set the path to the object list
Set folder = fs.GetFolder("" & path & "\" & ListFolder & "")
'now lets list the files
for each file in folder.Files
'exclude this file from list
If file.name <> "default.asp" then
%>
<tr>
<td width="100%" bgcolor="#FFFFFF">
<a href="<%= ListFolder %>/<%= file.name %>"><%= file.name %></a>
</td>
</tr>
<%
'end of default.asp exclusion from list
end if
'create and list next file in new row
next
'if you are seeing a list of files from a subfolder, then, show a row with a link to back to the list of subfolders
If Request.Querystring("list") <> "" Then
%>
<tr>
<td width="100%" bgcolor="#C0C0C0" align="center">
<a href="javascript:history.back(-1)">Back to the list of folders</a>
</td>
</tr>
<%
'end of row with the link to back to the subfolders
End If
%>
</table>
</center>
</div>

<!------------------------------end of file------------------------>

i have tested this codeand it work fine on my server. i put just 3 subfolders, now you modify it to add how many subfolders to list as you need. i have exclude the file default.asp from list, so, you can exclude other files from list too.

sorry about my english, its terrible... my asp too, but if i can help in anymore, just post again :)

[]'s for all;

Bborg

.



-------------
(sorry about my english... its terrible!!)
I also was born bare, bald and without teeth!!!


Posted By: Bborg
Date Posted: 07 September 2003 at 3:11pm

ow... sorry by continue this topic in wrong forum...
and other think; if you are running your site in your computer, yoy have another solution and better. just create a folder and give permissions to that folder to users can see a list of files if you not specify a default file; then go to default file options from this folder and remove any filename from list. if you are running your site on a free web server; this code will not work if your server does not have installed or no support the FileSysitemObject.



-------------
(sorry about my english... its terrible!!)
I also was born bare, bald and without teeth!!!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net