Contact Us

Let us know to help you out quickly!

 Admin User     Feb,08 2017

Get Drives List Using ColdFusion in Window

For one of my project where we were building file manager to give selection of server file, here we need list of drive letters to allow user to switch over drive. But I realize that cfdirectory doesn't give list of drives but obvioiusly our second choise is Java File component.

Below is code will retrive list of all drives.

<cfset fileObj = createObject("java","java.io.File") /><cfset systemRoots = fileObj.listRoots() /><cfloop from="1" to="#arrayLen(systemRoots)#" index="i"><cfoutput>#systemRoots[i].getAbsolutePath()#</cfoutput></cfloop>