You may misunderstand what the size field returns.  It returns the size of
each item in the directory listing, generally each individual file size.
For (sub)directories, I believe it just returns 0.

Your reference to spaceAvail.size is interpreted as spaceAvail.size[1], or
the size of the first row in the query.  Since your CFDIRECTORY doesn't
specify a SORT parameter it's sorting by name by default.  If I remember
correctly, like a DOS directory command, it will always return "." (the
directory itself) and ".." (the parent directory, except in the case where
the directory is the root of the drive).  These end up sorted at the
beginning of the query, so you're referencing the size of ".", and it being
a directory, you get 0.

I believe the only way to get the size of all the items in the directory is
to loop over each item and add up the file sizes.  Keep in mind this won't
add in the sizes of subdirectories unless you explicitly traverse them, also
using CFDIRECTORY.

There are a number of tags in the gallery that do this: cf_dirinfo,
cf_dirsize, cf_du among them.

Jim


----- Original Message -----
From: "Bryan LaPlante" <[EMAIL PROTECTED]>
To: "CF-Server" <[EMAIL PROTECTED]>
Sent: Sunday, March 18, 2001 10:31 PM
Subject: CFDIRECTORY.SIZE


> Hey gang,
> Is there any way to get cfdirectory to return the size of a direcotry. I
> have tried it in a recursive loop as well as the code below. It always
> returns 0. Any idea's?
>
>
> <CFDIRECTORY ACTION="LIST"
>              DIRECTORY="c:\inetpub\wwwroot"
>              NAME="SpaceAvail">
>
> <CFSET diskSpace = spaceAvail.size>
>
> Bryan LaPlante
> 816-347-8220
> [EMAIL PROTECTED]
> http://www.netwebapps.com
> Web Development


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
To unsubscribe, send a message to [EMAIL PROTECTED] with 
'unsubscribe' in the body or visit the list page at www.houseoffusion.com

Reply via email to