Click to See Complete Forum and Search --> : Counting number of files within a folder


Logz
04-28-2006, 10:28 AM
Hey,
Basically, I would like to count all the files in a particular folder.
Ive wrote this program, however, when I tested it, i realised none of the objects (FS and FO) support the "count" method.

Could anyone give me a hand here, if it is possible, to count the number of files within this certain folder.

My program so far:

<%
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("D:\WWWRoot\...siteaddress...\www\modules\txt\")

var_number_of_files=fs.count

set fo=nothing
set fs=nothing
%>


Thanks in advance

lmf232s
04-28-2006, 01:27 PM
Dim fso, folder, files, x
set fso = server.createObject("Scripting.FileSystemObject")
set folder = fso.GetFolder("Your Path")
set files = folder.Files

Response.write files.count

Set fso = Nothing

Logz
04-29-2006, 07:52 AM
Brilliant, thats exactly what I wanted *cheers* :)