Just a simple example how it could be done
<cfset currPath = ExpandPath("/")>
<cfset size = getSize(currPath)>
<cfoutput>Size: #size#</cfoutput>
<cffunction name="getSize" returntype="numeric">
<cfargument name="file" type="any" required="true">
<cfscript>
var size = 0;
var oFile = arguments.file;
var fileList = "";
var i = 0;
if( isSimpleValue(oFile) ) {
oFile = CreateObject("java",
"java.io.File").init(arguments.file);
}
if( oFile.isDirectory() ) {
fileList = oFile.listFiles();
for( i = 1; i lte ArrayLen(fileList); i = i + 1 ) {
size = size + getSize(fileList[i]);
}
}
else {
size = size + oFile.length();
}
return size;
</cfscript>
</cffunction>
On Mon, May 12, 2008 at 1:31 PM, Maximilian Nyman <[EMAIL PROTECTED]>
wrote:
> There's no other way then recursively looping over all
> sub-directories/files.
> And if you used some tool to do it before, it too would have done the same
> thing.
>
> But it shouldn't be that painful really - One method, with a File object
> as the argument, looping over the listFiles array, IF directory then
> recurse-call and add the result ELSE add the fileSize
>
> /Max
>
>
>
> On Mon, May 12, 2008 at 1:05 PM, Steve Onnis <[EMAIL PROTECTED]>
> wrote:
>
> >
> >
> > I was using the Scripting.FileSystemObject to get file sizes and folder
> > sizes for one of my applications but now I am running on a 64 bit system
> > and
> > the Scripting.FileSystemObject is a 32 bit application so I cant use it
> > now.
> >
> >
> > For files I am using the java.io.File class to get the file sizes but
> > have
> > hit a wall when trying to get folder sizes. I have looked at the
> > java.io.File class does not have a length() method that works on folders
> > to
> > get the folder sizes. It seems the only way to do it is to loop over
> > the
> > listFiles() array and add the file sizes up and then manually recurse
> > through any directories that might be in there. Seems like a bit of a
> > pain
> > really.
> >
> > Anyone got any better ideas? I have had a look at the .NET classes also
> > and
> > it seems the same thing is there, no more Size property of the
> > Directory.
> >
> > Steve
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---