I want to display the amount of free space on the local C: drive, on
the computer that coldfusion is running.
any suggestions please.
thanks
Garry
nkosi - 03 Jun 2009 05:13 GMT
Assuming you're on a Windows machine using CF8 these are two methods
that I am aware of:
1) Using .Net version 2 or greater - see
http://www.forta.com/blog/index.cfm/2007/5/30/GetDriveInfo-UDF-Powered-By-NET
2) Using Java -
<cfobject type="java" action="create" class="java.io.File"
name="objFile">
<cfobject type="java" action="create"
class="javax.swing.filechooser.FileSystemView" name="objFSVTemp">
<cfset arrRoots = objFile.listRoots()>
<cfset iArrayLen = ArrayLen(arrRoots)>
<cfset objFSV = objFSVTemp.getFileSystemView()>
<cfloop from="1" to="#iArrayLen#" index="i">
<cfoutput>
<strong>Drive: #arrRoots[i]#</strong><br />
Available Space: #arrRoots[i].getFreeSpace()#<br />
Total Space: #arrRoots[i].getTotalSpace()#<br />
<br />
</cfoutput>
</cfloop>
Hope that helps.
Cheers
Glen