getFreeSpace

Gets information about free hard disk space or free in-memory VFS space.

getFreeSpace(path); → returns numeric

getFreeSpace Argument Reference

path
Required

The Path to the Hard Disk Drive or to the in-memory file system - ram.

Examples sample code invoking the getFreeSpace function

In the following example, in-memory file system memory for the application is set to 20 MB in ColdFusion Administrator. The function returns 20, which means the total space considered is 20 MB. This is because the value specified in the ColdFusion Administrator (Memory Limit per Application for In-Memory Virtual File System) is lesser than the value specified in the Application.cfc (20 MB).Application.cfc

<cfcomponent> 
 <cfset this.name = 'vfs_total_space'> 
 <cfset this.inmemoryfilesystem.size = 30> 
 </cfcomponent> 

space.cfm

<cfset freeRAMSpace = getFreeSpace('ram:')>
 <cfset freeDiskSpace = getFreeSpace('c:')> 
 Free Application RAM Memory = #decimalFormat(freeRAMSpace / (1024 * 1024))# MB 
 <br>Free Hard Disk Space = #decimalFormat(freeDiskSpace / (1024 * 1024 * 1024))# GB  

Fork me on GitHub