Checking available free space from ColdFusion

Earlier today I noticed on Ray Camden's site a blog post about determining the amount of free space on a drive from ColdFusion. It looks like in CF10, a new function, getFreeSpace('path') was added that will return the amount of free space in MB back. Here's the article: http://www.raymondcamden.com/index.cfm/2013/1/22/Using-ColdFusion-to-check-available-disk-space

For those of us not yet on ColdFusion 10, the following article outlines how you can drill down to the Java File class to get the free space.

http://www.jozza.net/blog/measuring-disk-space-in-coldfusion/141/

In particular, pay attention to the second part, because with the .init() outlined, you can pass in an exact path. This can be handy with AWS, local file shares, etc.

So if you aren't on CF10 yet, you could put together your own custom CFC, to return the amount of free space, something as simple as:

With the function above, you can run a simple test case such as...

Your dump should look something like this:

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.