The example code below will display all the files that reside in the folder 'images' located in the root folder.
<%
Dim oFilesys, oFolder, oFile
Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFolder= oFilesys.GetFolder(Server.MapPath("/images/"))
For Each oFile in oFolder.Files
Response.write oFile.Name
Response.write "<br />"
Next
Set oFolder=Nothing
Set oFilesys=Nothing
%>
The example code below will display all the files that reside in the folder in which this script resides.
<%
Dim oFilesys, oFolder, oFile, oFileItem
Dim sPathInfo, sPhysicalPath
sPathInfo=Request.ServerVariables("PATH_INFO")
sPhysicalPath=Server.MapPath(sPathInfo)
Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFile=oFilesys.GetFile(sPhysicalPath)
Set oFolder= oFile.ParentFolder
For Each oFileItem in oFolder.Files
Response.write oFileItem.Name
Response.write "<br />"
Next
Set oFolder=Nothing
Set oFilesys=Nothing
%>
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.