Skip to main content
Participant
November 12, 2008
Answered

Determine free space on Windows volume

  • November 12, 2008
  • 1 reply
  • 455 views
Does CF 8 support easy way to determine free space on a volume on Windows 2003? I've done it via CFEXECUTE cmd.exe "dir /w" and parsing the result, but there must be a better way. Perhaps w/ Java object?
This topic has been closed for replies.
Correct answer -__cfSearching__-
Try using java.io.File. Read the api for the applicable disclaimers.
http://java.sun.com/javase/6/docs/api/java/io/File.html#getFreeSpace()

<cfset f = createObject("java", "java.io.File").init(pathToVolume)>
<cfset free = f.getFreeSpace() >
<cfset total = f.getTotalSpace() >

<!--- function found at: http://cflib.org/udf/ByteConvert --->
<cfoutput>
total = #byteConvert(total, "MB")#
free = #byteConvert(free, "MB")#
</cfoutput>

1 reply

-__cfSearching__-Correct answer
Inspiring
November 12, 2008
Try using java.io.File. Read the api for the applicable disclaimers.
http://java.sun.com/javase/6/docs/api/java/io/File.html#getFreeSpace()

<cfset f = createObject("java", "java.io.File").init(pathToVolume)>
<cfset free = f.getFreeSpace() >
<cfset total = f.getTotalSpace() >

<!--- function found at: http://cflib.org/udf/ByteConvert --->
<cfoutput>
total = #byteConvert(total, "MB")#
free = #byteConvert(free, "MB")#
</cfoutput>
bmwm3smgAuthor
Participant
November 12, 2008
Appears to work in my installation. Thank you.