This topic is locked

File list

6/28/2006 1:09:36 PM
ASPRunnerPro General questions
J
jawendell author

Is there a way to create a page in an application that when that page is selected, it actually presents a list of the files that are in a specified directory? I basically want to have a quick access to and list of files that are in a directory.
Any suggestions would be greatly appreciated.
Thanks!

Sergey Kornilov admin 6/28/2006

Something like this will work:

strDirectoryPath="c:\inetpub\scripts\"

strUrlPath="\scripts\"



'get file scripting object

Set objFileScripting = CreateObject("Scripting.FileSystemObject")

'Return folder object

Set objFolder = objFileScripting.GetFolder("c:\inetpub\scripts\")

'return file collection In folder

Set filecollection = objFolder.Files

'create the links

For Each filename In filecollection

Filename=right(Filename,len(Filename)-InStrRev(Filename, "\"))

Response.Write "<A HREF=""" & strUrlPath & filename & """>" & filename & "</A><BR>"

Next
J
jawendell author 6/28/2006

Thanks for your quick reply. Would I just place this code on a basic page? I realize I would need to substitute my directory into your example.
THanks!

J
jawendell author 6/29/2006

Something like this will work:

strDirectoryPath="c:\inetpub\scripts\"

strUrlPath="\scripts\"
'get file scripting object

Set objFileScripting = CreateObject("Scripting.FileSystemObject")

'Return folder object

Set objFolder = objFileScripting.GetFolder("c:\inetpub\scripts\")

'return file collection In folder

Set filecollection = objFolder.Files

'create the links

For Each filename In filecollection

Filename=right(Filename,len(Filename)-InStrRev(Filename, "\"))

Response.Write "<A HREF=""" & strUrlPath & filename & """>" & filename & "</A><BR>"

Next


Thanks for your feedback. I have one additional question. The hyperlinks that are created with the above code, how do I get them to open in a new window when clicked?
THanks for your assistance.

J
Jane 6/30/2006

Jerome,
use following code:

Response.Write "<A HREF=""" & strUrlPath & filename & """ target=_blank>" & filename & "</A><BR>"
J
jawendell author 6/30/2006

Jerome,

use following code:

Response.Write "<A HREF=""" & strUrlPath & filename & """ target=_blank>" & filename & "</A><BR>"


This worked perfectly. Thanks very much for your help.