March 30, 2005

Find free disk space available on Windows with CFMX

This code will list the fixed disks and the free available space on them.

<cfobject type="COM" action="create" class="Scripting.FileSystemObject" name="Application.fso">
<cfset driveSpace=StructNew()>
<cfloop collection="#Application.fso.drives#" item="curDrive">
<!--- A DriveType of 2 indicates a fixed disk --->
<cfif curDrive.DriveType IS 2>
<cfset driveSpace["#curDrive.DriveLetter#"]=curDrive.availablespace>
<cfoutput>#curDrive.DriveLetter#: #int(trim((curDrive.availablespace/1024)/1024))# MB free</cfoutput>
<br>
</cfif>
</cfloop>

No comments: