Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the size of a directory 1

Status
Not open for further replies.

iqof188

IS-IT--Management
Nov 9, 2000
228
GB
In Allaire's custom tag gallery there's several tags that can read the total size of a given directory on your server. Problem is that all of those tags are SLOOOOOOW all start looping and stuff, almost bringing down your server :) ). For all you IIS users, here's the quick solution:

<cfset MyFolder=&quot;c:\inetpub\
<cftry>
<cfobject type=&quot;COM&quot; name=&quot;FSO&quot; class=&quot;Scripting.FileSystemObject&quot; action=&quot;CONNECT&quot;>
<cfcatch>
<cfobject type=&quot;COM&quot; name=&quot;FSO&quot; class=&quot;Scripting.FileSystemObject&quot; action=&quot;CREATE&quot;>
</cfcatch>
</cftry>

<cfscript>
objFolder=FSO.getFolder(MyFolder);
objFolderSize=objFolder.size;
</cfscript>

<cfoutput>#MyFolder# is #Evaluate(oFolderSize / 1000000)# Megabytes!</cfoutput>

Good luck with it!


<webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top