Reading filenames in a folder

S

Steve Karnath

Hi All,

I would like to read the contents of folder and display
filtered results in my page. Can someone point me in a
direction just to get me started, Thanks.

TIA

Best Regards,
Steve Karnath
 
M

Martin CLAVREUIL

in order to list a folder content you can use a function like this one :

' The filtering condition is extention=htm

---<Code to paste>---
Const MyFolder="d:\Files"

set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set Fld=Fso.getFolder(MyFolder)
for each F in Fld.File
if lcase(right(F.Name,3))="htm" then
response.write F.Name & "<br>"
end if
next
---</Code to paste>---
 
R

Ray at home

<%
Const PATH_ON_SERVER = "D:\Path"

Dim oFSO, oDir
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oDir = oFSO.GetFolder(PATH_ON_SERVER)
For Each oFile In oDir.File
Response.Write oFile.Name & "<br>"
Next
Set oDir = Nothing
Set oFSO = Nothing
%>

For your filtering, use if/then on whatever file property you'd like to
filter by. To see what properties would be available for each oFile in
oDir, see
http://msdn.microsoft.com/library/en-us/script56/html/jsobjFile.asp

Ray at home
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top