"Dir" in ASP

07-11-2002, 08:44 PM
Hi All,

does anyone know what is the equivalent function in ASP for "Dir" function in Visual Basic?

I'm trying to put all the files in one directory into a collection.

Thank you


07-11-2002, 08:50 PM
You need to use the Scripting.FileSystemObject. Here's an example:Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Get the folder object associated with the directory
Dim objFolder
Set objFolder = objFSO.GetFolder("C:\InetPub\wwwroot")

Response.Write "The files found in " & objFolder.Name & ":<br>"

'Loop through the Files collection
Dim objFile
For Each objFile in objFolder.Files
Response.Write objFile.Name & "<br>"

'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum