Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Directory Listing
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Directory Listing

 Post Reply Post Reply
Author
webpromo View Drop Down
Groupie
Groupie


Joined: 25 February 2002
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote webpromo Quote  Post ReplyReply Direct Link To This Post Topic: Directory Listing
    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.

Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post Posted: 07 September 2003 at 10:39am
Post in the right forum!
Back to Top
webpromo View Drop Down
Groupie
Groupie


Joined: 25 February 2002
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote webpromo Quote  Post ReplyReply Direct Link To This Post Posted: 07 September 2003 at 10:55am

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

Sorry.

Back to Top
Bborg View Drop Down
Newbie
Newbie
Avatar

Joined: 24 April 2003
Location: Portugal
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bborg Quote  Post ReplyReply Direct Link To This Post 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

.

Back to Top
Bborg View Drop Down
Newbie
Newbie
Avatar

Joined: 24 April 2003
Location: Portugal
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bborg Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.