Hello, Bryan.

It would make sense that the CFDIRECTORY tag would return the size of the
content of the directory, but rather it seems that it is returning the size
of the directory name itself, which is zero bytes.

You can recurse through the directory contents and add up the file sizes one
by one.

Here is my example:
Create a custom tag called CF_DirSize with the following content:

<!--- Start of Custom tag --->
<!--- 
Attributes:
Directory - Path and Name of the directory (i.e. "C:\windows")
Subdirectory - Include subdirectories below the directory provided; "Y" =
Yes, "N" = No
Returns variable "Directorysize"
--->

<CFPARAM NAME="attributes.Directory" DEFAULT="C:\">
<CFPARAM NAME="attributes.Subdirectory" DEFAULT="N">

<CFSET DirSize = 0>
<CFdirectory directory="#attributes.Directory#" NAME="DirList" SORT="Type
ASC" ACTION="LIST">
<CFOUTPUT QUERY="DirList">
        <CFIF DirList.type EQ "Dir">
                <CFIF attributes.Subdirectory EQ "Y" AND DirList.name NEQ
"." AND DirList.name NEQ "..">
                        <CF_DirSize
Directory="#attributes.Directory#\#dirlist.name#"
Subdirectory="#attributes.Subdirectory#">
                        <CFSET variables.DirSize = variables.DirSize +
DirectorySize>
                </CFIF>
        <CFELSEIF DirList.type EQ "File">
                <CFSET DirSize = DirSize + DirList.Size>
        </CFIF>
</CFOUTPUT>
<CFSET Caller.DirectorySize = variables.DirSize>

<!--- End of Custom tag --->

Then call the custom tag with the following line of code:
<CF_DirSize Directory="c:\winnt" Subdirectory="N">
<CFOUTPUT>Directory Size = #DirectorySize#</CFOUTPUT>

This works for me.

Randy Ellis
City of Overland Park
[EMAIL PROTECTED]
913-895-6059

-----Original Message-----
From: Bryan LaPlante [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 18, 2001 11:31 PM
To: [CF-Server List][E-Mail]
Cc: [KCFusion List] (E-mail)
Subject: [KCFusion] 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

 
 
______________________________________________________________________
The KCFusion.org list and website is hosted by Humankind Systems, Inc.
List Archives........ http://www.mail-archive.com/cf-list@kcfusion.org
Questions, Comments or Glowing Praise.. mailto:[EMAIL PROTECTED]
To Subscribe.................... mailto:[EMAIL PROTECTED]
To Unsubscribe................ mailto:[EMAIL PROTECTED]
 
 
 
______________________________________________________________________
The KCFusion.org list and website is hosted by Humankind Systems, Inc.
List Archives........ http://www.mail-archive.com/cf-list@kcfusion.org
Questions, Comments or Glowing Praise.. mailto:[EMAIL PROTECTED]
To Subscribe.................... mailto:[EMAIL PROTECTED]
To Unsubscribe................ mailto:[EMAIL PROTECTED]
 

Reply via email to